1
votes

Whenever I connect my client to send data to my WCF Azure service, I get this 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."

I've read everywhere about setting this MaxReceivedMessageSize property on both the client and server config files. I have done this.

However, whenever I update the service reference in the client, it pulls the settings back to the default of 65536. (found via investigating the .svcinfo file)

This leads me to conclude the issue must be on the service side.

I've placed this in my web.config file:

<bindings>
  <basicHttpBinding>
    <!--The basicHttpBinding is used for clients which use the generated code to transmit data; the following settings make it possible to send larger amounts to the service-->
    <binding maxReceivedMessageSize="10000000" receiveTimeout="01:00:00">
      <readerQuotas maxStringContentLength="10000000" />
    </binding>
  </basicHttpBinding>
</bindings>

Now, many posts talk about naming the binding and setting it in the service endpoints on the server side as well. Something like this:

<services>
   <service name="YourNamespace.YourServiceClass">
       <endpoint name="endpoint1"
             address="http://server:8888/YourService.svc" 
             binding="basicHttpBinding"
             bindingConfiguration="lageMessageTransfer"
             contract="IYourServiceContract" />
   </service>
</services>

However, I don't have these service endpoints and my service works great for small sizes.

Where else would this need to be set?

EDIT:

More information, Tim seems to be on the right track with the default endpoints. I am using a default endpoint. It seems that you cannot just explicitly define a service for that default endpoint. or if you can, I must be doing it incorrectly.

However, it seems that you can modify the binding on a default endpoint as stated by Richard. This is done by simply not specifying a name for the binding. I have tried setting the values on my service to much lower values to see if something else was lowering them, but they are completely ignored. Its as if the default endpoint is simply ignoring the binding that I have created.

For my entire config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
  <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
    <listeners>
      <add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="logging.e2e" />
    </listeners>
  </source>
</sources>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0">
  <assemblies>
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral,  PublicKeyToken=b77a5c561934e089" />
  </assemblies>
</compilation>
</system.web>
<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding maxReceivedMessageSize="100" maxBufferSize="100" receiveTimeout="00:11:00">
      <readerQuotas maxStringContentLength="100" />
    </binding>
  </basicHttpBinding>
</bindings>

<protocolMapping>
  <add scheme="http" binding="basicHttpBinding" />
</protocolMapping>

<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<connectionStrings><EDITEDOUT></connectionStrings>
</configuration>

Thoughts on why the new binding settings are not being picked up?

2
Unfortunately, to my knowledge, you're stuck if you can't modify the service's configuration. If you absolutely cannot modify the service's configuration you'll need to take steps to ensure that your payload is less than the 65536 byte maximum.GunnerL3510
I can modify the server's configuration, however, it will not pick up the new settings.Jared

2 Answers

1
votes

The attribute name maxReceivedMessageSize is very explicit - it all depends on who is receiving the message - if you are sending a large amount of data then it is the service, if you are getting a large amount of data back from the service then it is the client. The service and client do not need the same value for this setting (unlike many other binding settings)

Setting an unnamed binding section should work in general as, of .NET 4, it configures the binding for anyone who doesn't explicitly specify a configuration using bindingConfiguration. However, in your example above you need to set the maxBufferSize in addition to the maxReceivedMessageSize as you are buffering rather than streaming the message. The maxBufferSize and maxReceivedMessageSize must be the same

0
votes

You don't have the section in the Web.config on your service side? If you're using WCF 4.0 is it possible you're using a default endpoint?

I don't know if you can specify a binding for a default endpoint, but you might want to try specifying an endpoint via the section of the Web.config and setting bindingConfiguration to the binding specified in your section.