简体   繁体   中英

Request entity too large error(413) in WCF

I am facing 413 error in WCF service even if maxReceivedMessageSize is set to max ie 2147483647 and actual message size is less than 50kb.

This issue appears only when there is some ideal time between two request. The exact scenario is as below: 1. Send 1000 messages each of them is around 38 kb. STATUS: PASS 2. Wait for sometime(Minimum 3 mins) 3. Send 1 message. STATUS: FAIL. (413 error)

I am using ws2007FederationHttpBinding. Web.config tag is as below:

<ws2007FederationHttpBinding>
    <binding name="federationHttpBinding" openTimeout="00:04:00" closeTimeout="00:04:00" receiveTimeout="00:04:00" sendTimeout="00:40:00" maxReceivedMessageSize="2147483647">
      <!-- <readerQuotas maxArrayLength="2147483647" maxDepth="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" /> -->
      <security mode="TransportWithMessageCredential">
        <message establishSecurityContext="false">
        </message>
      </security>
    </binding>
  </ws2007FederationHttpBinding>

Client side binding tag is as below:

<ws2007FederationHttpBinding>
    <binding name="AuthorizationBinding" openTimeout="00:04:00" closeTimeout="00:04:00" receiveTimeout="00:04:00" sendTimeout="00:40:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
      <readerQuotas maxArrayLength="2147483647" maxDepth="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
      <security mode="TransportWithMessageCredential">
        <message establishSecurityContext="false"/>
      </security>
    </binding>
</ws2007FederationHttpBinding>

You also have to set maxBufferSize

    <binding name="federationHttpBinding" 
             maxReceivedMessageSize="2147483647" 
             maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647">

I think you could solve this problem by removing the name attribute from the binding tag, A similar problem could be found here

WCF service maxReceivedMessageSize basicHttpBinding issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM