Wednesday, September 07, 2011

WCF–sending large messages to the server

For the server to be able to accept large messages from clients you don’t only have to change the “maxReceivedMessageSize” and “maxBufferSize”, but also the HttpRuntime’s maxRequestLength. Without the maxRequestLength being set, large messages will get thrown out by the server.

<httpRuntime maxRequestLength="102400"/>

    <binding name="myBinding" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
     maxBufferSize="2147483647 " maxReceivedMessageSize="2147483647" maxBufferPoolSize="524288" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
     <readerQuotas maxDepth="32" maxStringContentLength="819200" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />

If you have One-Way operations, and you attempt to send data that’s larger than the httpRuntime.maxRequestLength value (default is 4mb), then you will not see any errors from the server. Instead you will most probably see a 504 error.

No comments: