Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.

Sponsors

News

 
 
 
DZone MVB

Links

Social

WCF: The maximum message size quota for incoming messages (65536) has been exceeded

When using WCF services you may get the following error: "The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element." This error is given because of size limits set to responses in your application configuration.

You need to increase the value of two limiting parameters: maxBufferSize and maxReceivedMessageSize. In my example these values are set to 5000000.


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding 
                    name="MyServiceConsumerBinding" 
                    closeTimeout="00:01:00"
                    openTimeout="00:01:00" 
                    receiveTimeout="00:10:00" 
                    sendTimeout="00:01:00"
                    allowCookies="false" 
                    bypassProxyOnLocal="false" 
                    hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="5000000" 
                    maxBufferPoolSize="524288" 
                    maxReceivedMessageSize="5000000"
                    messageEncoding="Text" 
                    textEncoding="utf-8" 
                    transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas 
                        maxDepth="32" 
                        maxStringContentLength="8192" 
                        maxArrayLength="16384"
                        maxBytesPerRead="4096" 
                        maxNameTableCharCount="16384" />
                    <security  mode="None">
                        <transport 
                            clientCredentialType="None" 
                            proxyCredentialType="None"
                            realm="" />
                        <message 
                          clientCredentialType="UserName" 
                          algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint 
address="http://localhost:12221/"
                binding="basicHttpBinding" 
bindingConfiguration="MyService"
                contract="MyService.MyServiceInterface" 
name="MyServiceConsumer"
/>
        </client>
    </system.serviceModel>
</configuration>

After increasing these values your service requests should work normally.

Comments

Xiao said:

You got a typo in your second paragraph for maxBufferSize as maxBufferSite.

# November 1, 2010 10:38 PM

DigiMortal said:

Thanks, Xiao! Just removed this typo.

# November 1, 2010 11:35 PM

kushalkhera06 said:

I am facing the same problem. Tried increasing the maxBuffersize as well as maxReceivedMessageSize. But still no response. Error: 400 Bad request

# December 26, 2011 7:18 AM

Mangesh said:

I am facing the same problem. Tried increasing the maxBuffersize as well as maxReceivedMessageSize. But still no response. Error: 400 Bad request

Also tried high values for other values in config above, but still same Bad Request.

Anyone else have been able to resolve this even after increasing all values?

# July 25, 2012 3:22 PM