0

Clients are calling my WCF method with too big xml (about 30mb when saved to a file) and IIS is returning 413. I tried setting the uploadReadAheadSize to 2gb; didn't work. Also tried increasing the binding's maxBufferSize to 2gb.

My WCF service is hosted on load balancer with couple of servers; I couldn't test isolated due to certificate validations in place. The thing I didn't try is Negotiate client certificate, which we don't want to change considering the broad consumers of other services.

With the default 48kb for uploadReadAheadSize, I was able to test 7mb sized xml string and it worked. All the findings on stack overflow / google show uploadReadAheadSize should fix it.. I am not sure what am I doing wrong. The client could be non .net client, which I have less control over.

DHAR
  • 63
  • 11
  • The answer to this question may help you:https://techcommunity.microsoft.com/t5/iis-support-blog/413-request-entity-too-large-when-connecting-to-a-wcf-service/ba-p/333384 – Theobald Du Feb 03 '21 at 05:28

1 Answers1

0

That is not problem of IIS but the problem of WCF. WCF by default limits messages to 65KB to avoid denial of service attack with large messages. Also if you don't use MTOM it sends byte[] to base64 encoded string (33% increase in size) => 48KB * 1,33 = 64KB

To solve this issue you must reconfigure your service to accept larger messages. This issue previously fired 400 Bad Request error but in newer version WCF started to use 413 which is correct status code for this type of error.

You need to set maxReceivedMessageSize in your binding. You can also need to set readerQuotas.

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding maxReceivedMessageSize="12345.......">
        <readerQuotas ... />
      </binding>
    </basicHttpBinding>
  </bindings>  
</system.serviceModel>

https://stackoverflow.com/a/10123764/6459462