Sometimes there are situations which require transfer of large messages when using web services. When working with WCF you will run in this issue very easy. The most prominent error message in this context is probably “The remote server returned an error: (404) Not Found.”.
You have to notice that this message is thrown either by processing of request inside of Service Model at the server side or by processing of request inside of HTTP pipeline in IIS.
WCF stack tuning
Usually you should enable WCF tracing at service side to figure out what is going on.If the error is caused by WCF you will find warning or errors which describe briefly what to do.One of solution for such issues if to increase maxBufferPoolSize, maxBufferSize or even readerQuotas. Here is great post Yi-Lun which describes undocumented details about how this works.
IIS http runtime tuning
Unfortunately there are messages which break through IIS defined limits. In this case you will get again “The remote server returned an error: (404) Not Found.”, but this time WCF Trace Viewer will not write any error. This is because the message does not reach WCF stack at all, It is rejected by IIS.
To fix this problem try following:
<system.web>
<httpRuntime maxRequestLength="2147483647" />
</system.web>
IIS request Content tuning
If previous two workaround do not work, there is one more (last) chance to get it working, You need to setup the IIS content length of one request.
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2000000000" />
</requestFiltering>
</security>
</system.webServer>
Last but not least, this post describes issues which happen, when sending messages larger than 10MB or 50MB. I would recommend to use streaming in such cases rather than default buffered transfer. It is faster and it does not require large buffer sizes.
Posted
Oct 13 2011, 05:53 PM
by
Damir Dobric