Friday, 11 December 2009

WCF: limits

Today I have lost a half of the day trying to understand a problem occurring when a .Net client was communicating to a server talking via WCF - when the posted byte array size was over circa 2MB.

Both client and server looked to be fine in term of limits:

moWsHttpBinding = New WSHttpBinding(System.ServiceModel.SecurityMode.None) moWsHttpBinding.MaxReceivedMessageSize = Integer.MaxValue
moWsHttpBinding.ReaderQuotas.MaxArrayLength = Integer.MaxValue
moWsHttpBinding.ReaderQuotas.MaxStringContentLength = Integer.MaxValue
moWsHttpBinding.MessageEncoding = WSMessageEncoding.Mtom
moWsHttpBinding.ReaderQuotas.MaxBytesPerRead = Integer.MaxValue
moWsHttpBinding.ReaderQuotas.MaxNameTableCharCount = Integer.MaxValue
moWsHttpBinding.UseDefaultWebProxy = False
moWsHttpBinding.BypassProxyOnLocal = True
moWsHttpBinding.ReceiveTimeout = New TimeSpan(20, 0, 0)
moWsHttpBinding.SendTimeout = New TimeSpan(20, 0, 0)

Server (from web config - omitting a lot of detals on how they are bounded)
<binding name="NoneBind" messageEncoding="Mtom" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

<security mode="None" />


... and as usually a solution was simple and laid outside of this code (and actually well known for me from development experience): you have to add into web.config something like:
<httpRuntime maxRequestLength="131072"/>

to increase the limit to circa 128MB.

which makes me wonder why remaining binding settings disallow to overcome this simple general one.

No comments: