WCF - Cómo Aumentar la Cuota de Tamaño de Mensaje


Tengo un servicio WCF que devuelve 1000 registros de la base de datos al cliente. Tengo un ASP.NET Cliente WCF (he añadido referencia de servicio en asp.net proyecto de aplicación web para consumir WCF).

Recibo el siguiente mensaje cuando corro la aplicación cliente:

La cuota máxima de tamaño de mensaje para los mensajes entrantes (65536) ha sido exceder. Para aumentar la cuota, utilice la propiedad maxReceivedMessageSize en el elemento vinculante apropiado.

Cualquiera ayuda? ¿Cómo aumentar la cuota de tamaño de mensaje?

Author: marc_s, 2009-05-19

13 answers

Querrá algo como esto para aumentar las cuotas de tamaño de mensaje, en la aplicación .config o Web.config archivo:

<bindings>
    <basicHttpBinding>
        <binding name="basicHttp" allowCookies="true"
                 maxReceivedMessageSize="20000000" 
                 maxBufferSize="20000000"
                 maxBufferPoolSize="20000000">
            <readerQuotas maxDepth="32" 
                 maxArrayLength="200000000"
                 maxStringContentLength="200000000"/>
        </binding>
    </basicHttpBinding>
</bindings>

Y utilice el nombre de enlace en su configuración de endpoint, por ejemplo,

...
bindingConfiguration="basicHttp"
...

La justificación de los valores es simple, son lo suficientemente grandes como para acomodar la mayoría de los mensajes. Puede ajustar ese número para que se ajuste a sus necesidades. El valor predeterminado bajo está básicamente ahí para prevenir ataques de tipo DOS. Hacerlo 20000000 permitiría un distribuido Ataque DOS para ser efectivo, el tamaño predeterminado de 64k requeriría un gran número de clientes para dominar la mayoría de los servidores en estos días.

 551
Author: Nate,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-12-09 09:30:07

Si todavía está recibiendo este mensaje de error mientras usa el Cliente de prueba WCF, es porque el cliente tiene una configuración separada maxBufferSize.

Para corregir el problema:

  1. Haga clic con el botón derecho en el nodo Config File en la parte inferior del árbol
  2. Seleccione Editar con SvcConfigEditor

Aparecerá una lista de ajustes editables, incluido maxBufferSize.

Nota: Clientes proxy generados automáticamente también establezca maxBufferSize en 65536 de forma predeterminada.

 137
Author: Michael Rodrigues,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-05-21 19:44:40

Si está creando sus enlaces WCF dinámicamente, aquí está el código a usar:

BasicHttpBinding httpBinding = new BasicHttpBinding();
httpBinding.MaxReceivedMessageSize = Int32.MaxValue;
httpBinding.MaxBufferSize = Int32.MaxValue;
// Commented next statement since it is not required
// httpBinding.MaxBufferPoolSize = Int32.MaxValue;
 85
Author: Bharath K,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-29 14:32:43

El Cliente de prueba WCF tiene su propia configuración de cliente.

Ejecute el cliente de prueba y desplácese hasta la parte inferior. Si hace doble clic en el nodo de archivo de configuración, verá la representación XML. Como puedes ver, maxReceivedMessageSize es 65536.

Para editar esto, haga clic derecho en el nodo del árbol de archivos de configuración y seleccione Editar Con SvcConfigEditor. Cuando el editor abra expandir enlaces y haga doble clic en el enlace que se generó automáticamente.

Puede editar todas las propiedades aquí, incluyendo maxReceivedMessageSize. Cuando haya terminado, haga clic en Archivo - Guardar .

Por último, cuando esté de vuelta en la ventana Cliente de prueba de WCF, haga clic en Herramientas - Opciones.

NOTA: Desmarque la configuración Siempre regenerar al iniciar servicios .

 39
Author: Jodee Dex Page,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-02-17 11:40:39

Encontré el camino fácil

- - - haga clic con el botón derecho en el archivo de configuración de webconfig o app y haga clic en EDITAR CONFIGURACIÓN de WCF y vaya a bingdigs y seleccione yore service y right lado mostrar maxResiveMessageSize dar un gran número - - -

 16
Author: NC64,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-03-30 06:39:22

Resuelvo el problema {de la siguiente manera

    <bindings>
  <netTcpBinding>
    <binding name="ECMSBindingConfig" closeTimeout="00:10:00" openTimeout="00:10:00"
      sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
      maxReceivedMessageSize="2147483647" portSharingEnabled="true">
      <readerQuotas maxArrayLength="2147483647" maxNameTableCharCount="2147483647"
          maxStringContentLength="2147483647" maxDepth="2147483647"
          maxBytesPerRead="2147483647" />
      <security mode="None" />
    </binding>
  </netTcpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="ECMSServiceBehavior">
      <dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483647" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceTimeouts transactionTimeout="00:10:00" />
      <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="100"
        maxConcurrentInstances="100" />
    </behavior>
  </serviceBehaviors>
</behaviors>
 7
Author: Rajesh Kuamr Chekuri,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-22 05:36:14

<bindings>
  <wsHttpBinding>
    <binding name="wsHttpBinding_Username" maxReceivedMessageSize="20000000"          maxBufferPoolSize="20000000">
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName" establishSecurityContext="false"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<client>
  <endpoint
            binding="wsHttpBinding"
            bindingConfiguration="wsHttpBinding_Username"
            contract="Exchange.Exweb.ExchangeServices.ExchangeServicesGenericProxy.ExchangeServicesType"
            name="ServicesFacadeEndpoint" />
</client>

 6
Author: Hemant Soni,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-01-26 12:38:19

Resolví mi problema en Bing Maps WPF en mi proyecto Usando CalculateRoute (). La solución en mi caso fue configurar maxReceivedMessageSize y maxReceivedMessageSize en el atributo " httpTransport "para la sección" CustomBinding".

Configuré las aplicaciones.archivo de configuración (es. myApp.config) esta configuración:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IGeocodeService" />
            <binding name="BasicHttpBinding_IRouteService" />
        </basicHttpBinding>
        <customBinding>
            <binding name="CustomBinding_IGeocodeService">
                <binaryMessageEncoding />
              <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                                maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
                                bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
                                keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
                                realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                                useDefaultWebProxy="true" />
            </binding>
            <binding name="CustomBinding_IRouteService">
                <binaryMessageEncoding />
              <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                                maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
                                bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
                                keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
                                realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                                useDefaultWebProxy="true" />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGeocodeService"
            contract="BingServices.IGeocodeService" name="BasicHttpBinding_IGeocodeService" />
        <endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc/binaryHttp"
            binding="customBinding" bindingConfiguration="CustomBinding_IGeocodeService"
            contract="BingServices.IGeocodeService" name="CustomBinding_IGeocodeService" />
        <endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRouteService"
            contract="BingServices.IRouteService" name="BasicHttpBinding_IRouteService" />
        <endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/binaryHttp"
            binding="customBinding" bindingConfiguration="CustomBinding_IRouteService"
            contract="BingServices.IRouteService" name="CustomBinding_IRouteService" />
    </client>
</system.serviceModel>
 6
Author: Francesco Germinara,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-05-11 00:07:27

Otra cosa importante a considerar desde mi experiencia..

Recomiendo encarecidamente NO maximizar maxBufferPoolSize, porque los búferes del grupo nunca se liberan hasta que el dominio de la aplicación (es decir, el Grupo de aplicaciones) se recicla.

Un período de alto tráfico podría causar que se use mucha memoria y nunca se libere.

Más detalles aquí:

 3
Author: Valerio Gentile,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:26:20

No olvides que la aplicación.se considerará la configuración del punto de entrada de ejecución, no la del proyecto de biblioteca de clases que administra llamadas a servicios Web si existe.

Por ejemplo, si obtiene el error mientras ejecuta unit test, debe configurar la configuración apropiada en el proyecto testing.

 2
Author: Gab,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-07-26 07:54:36

Recibí este error al usar esta configuración en la web.config

System.ServiceModel.ServiceActivationException

Establezco configuraciones como esta:

      <service name="idst.Controllers.wcf.Service_Talks">
    <endpoint address="" behaviorConfiguration="idst.Controllers.wcf.Service_TalksAspNetAjaxBehavior"
      binding="webHttpBinding" contract="idst.Controllers.wcf.Service_Talks" />
  </service>
  <service name="idst.Controllers.wcf.Service_Project">
    <endpoint address="" behaviorConfiguration="idst.Controllers.wcf.Service_ProjectAspNetAjaxBehavior"
      binding="basicHttpBinding" bindingConfiguration="" bindingName="largBasicHttp"
      contract="idst.Controllers.wcf.Service_Project" />
  </service>
</services>

<bindings>
<basicHttpBinding>
    <binding name="largBasicHttp" allowCookies="true"
             maxReceivedMessageSize="20000000"
             maxBufferSize="20000000"
             maxBufferPoolSize="20000000">
        <readerQuotas maxDepth="32"
             maxArrayLength="200000000"
             maxStringContentLength="200000000"/>
    </binding>
</basicHttpBinding>

 1
Author: FARHAD AFSAR,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-01-22 09:53:41

Para HTTP:

<bindings>
  <basicHttpBinding>
    <binding name="basicHttp" allowCookies="true"
             maxReceivedMessageSize="20000000" 
             maxBufferSize="20000000"
             maxBufferPoolSize="20000000">
        <readerQuotas maxDepth="200" 
             maxArrayLength="200000000"
             maxBytesPerRead="4096"
             maxStringContentLength="200000000"
             maxNameTableCharCount="16384"/>
    </binding>
  </basicHttpBinding>
</bindings>

Para TCP:

<bindings>
  <netTcpBinding>
    <binding name="tcpBinding"
             maxReceivedMessageSize="20000000"
             maxBufferSize="20000000"
             maxBufferPoolSize="20000000">
      <readerQuotas maxDepth="200"
           maxArrayLength="200000000"
           maxStringContentLength="200000000"
           maxBytesPerRead="4096"
           maxNameTableCharCount="16384"/>
    </binding>
  </netTcpBinding>
</bindings>

IMPORTANTE:

Si intenta pasar un objeto complejo que tiene muchos objetos conectados (por ejemplo: una estructura de datos de árbol, una lista que tiene muchos objetos...), la comunicación fallará sin importar cómo aumentaste las Cuotas. En tales casos, debe aumentar el número de objetos que contienen:

<behaviors>
  <serviceBehaviors>
    <behavior name="NewBehavior">
      ...
      <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
 1
Author: Jacob,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-25 10:27:06

Para mí, todo lo que tenía que hacer era agregar maxReceivedMessageSize="2147483647" a la aplicación cliente.config. El servidor quedó intacto.

 0
Author: ashilon,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-24 14:50:15