The maximum message size quota for incoming messages has been exceeded (obvious fix not helping)
Asked Answered
B

2

6

I have an application which is uploading large files using WCF with netTcpBinding. For a particular file, i'm getting the error message:

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.

Here is my binding on the client web.config file (client is an ASP.NET website):

    <binding name="DataImportEndpoint" closeTimeout="00:20:00" openTimeout="00:01:00"
      receiveTimeout="00:20:00" sendTimeout="00:20:00" transferMode="Buffered"
      hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
      maxBufferSize="5242880" maxReceivedMessageSize="5242880">
      <readerQuotas maxDepth="32" maxStringContentLength="524288" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="Transport">
        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
      </security>
    </binding>

I realized I also needed to change the maxReceivedMessageSize property for the service config. So i added this binding:

<bindings>
  <netTcpBinding>
    <binding name="NetTcpLarge"
             maxReceivedMessageSize="5242880" maxBufferSize="5242880">
      <readerQuotas maxStringContentLength="524288"/>
    </binding>
  </netTcpBinding>
</bindings>

and modified my endpoint:

<endpoint address="DataImportService" binding="netTcpBinding"
       name="DataImportEndpoint" bindingConfiguration="NetTcpLarge"
       contract="IDataImportService" />

This fixed the problem when i run self hosted in Visual Studio. But on an instance running on IIS 7, i'm still getting the same error that 65536 has been exceeded. Am i missing something here? i even added this to my service config in IIS 7 instance, but to no avail:

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="5242880" />
        </requestFiltering>
    </security>
</system.webServer>
Bireme answered 9/4, 2011 at 21:24 Comment(0)
D
6

If the exception is still same with IIS, it has nothing to do with <requestLimits>, the exception clearly indicates that maxReceivedMessageSize is exceeded. I'd capture the WCF traces at verbose level and check what binding configuration is applied on endpoint.

I'd suggest you to recheck the client and service configuration and if still no clue, capture traces for service and client at verbose level.

Disjoin answered 10/4, 2011 at 18:55 Comment(1)
Indeed, the binding configuration was NOT being applied. The service name from the web.config didn't not match service name from the .svc file (one had full namespace) and because of that, the default endpoints were being applied! thanks for suggestionBireme
C
0

Sounds like you may be exceeding IIS's "maxRequestLength" buffer size. The default size is... you guessed, 65536. Try adding the following lines to your web.config file:

<system.web>
    <compilation debug="true"/>
    <httpRuntime maxRequestLength="5242880"/>
</system.web>
Casein answered 10/8, 2011 at 18:38 Comment(1)
The default size is 4096 KB (4 MB). msdn.microsoft.com/en-us/library/…Pyrope

© 2022 - 2024 — McMap. All rights reserved.