14

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.

<system.serviceModel>

<services>
  <service name="FileService.Service1" behaviorConfiguration="FileService.Service1Behavior">
    <host>
      <baseAddresses>
        <add baseAddress = "http://localhost:8732/Design_Time_Addresses/FileService/Service1/" />
      </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint address ="" binding="wsHttpBinding" contract="FileService.IService1">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <!-- Metadata Endpoints -->
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="FileService.Service1Behavior">
      <!-- To avoid disclosing metadata information, 
      set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="True"/>
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true.  Set to false before deployment 
      to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
  </behaviors>
  </system.serviceModel>
Tarantino
  • 201
  • 1
  • 3
  • 7

1 Answers1

26

You should set maxReceivedMessageSize="2147483647" to increase message size. Try to change config to this:

<binding maxBufferSize="2147483647" 
         maxBufferPoolSize="2147483647" 
         maxReceivedMessageSize="2147483647">
    <readerQuotas maxDepth="2147483647" 
                  maxStringContentLength="2147483647" 
                  maxArrayLength="2147483647" 
                  maxBytesPerRead="2147483647"
                  maxNameTableCharCount="2147483647" />
</binding>

But it is a bad practice to increase you message values to max value. This can lead you to serious troubles with DOS leaks.

UPDATED:

<system.serviceModel>
  <bindings>
   <wsHttpBinding>
    <binding name="wsBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"  >
      <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
    </binding>
   </wsHttpBinding> 
  </bindings>
  <services>
  <service name="FileService.Service1" behaviorConfiguration="FileService.Service1Behavior">
  <host>
    <baseAddresses>
      <add baseAddress = "http://localhost:8732/Design_Time_Addresses/FileService/Service1/" />
    </baseAddresses>
  </host>
   <endpoint address ="" binding="wsHttpBinding" bindingConfiguration="wsBinding" contract="FileService.IService1">   
   <identity>
    <dns value="localhost"/>
   </identity>
 </endpoint>

 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
 </service>
 </services>
 <behaviors>
   <serviceBehaviors>
     <behavior name="FileService.Service1Behavior">    
       <serviceMetadata httpGetEnabled="True"/>    
       <serviceDebug includeExceptionDetailInFaults="False" />
     </behavior>
   </serviceBehaviors>
 </behaviors>
</system.serviceModel>
Alex
  • 8,827
  • 3
  • 42
  • 58
  • where should i mention this in the app.config,i did this, but its giving error – Tarantino Oct 24 '13 at 11:06
  • @Tarantino Show your config. This should be set inside your binding configuration. – Alex Oct 24 '13 at 11:09
  • i have not set any bindings in app.config, under which binding i should set that – Tarantino Oct 24 '13 at 11:11
  • @Tarantino You should have a section in your config. This section describes your WCF service connetion properties (binding section and endpoint section). The binding section describes the connection properties like protocol, security, meassage size, transactions and so on. The endpoint section takes the properties from binding section and uses them to consume your service. Update your question and show full config. – Alex Oct 24 '13 at 11:17
  • @Tarantino i updated my answer. You should do the same thing on your client. And I advice you to read some theory about wcf configuration basics. – Alex Oct 24 '13 at 12:18
  • even now im getting the same error....im not using any client application now,just running the service and invoking it – Tarantino Oct 24 '13 at 12:25
  • @Tarantino how do you invoke it? – Alex Oct 24 '13 at 12:28
  • @Tarantino Welcome to SO :) – Alex Oct 24 '13 at 12:50
  • 1
    As you are saying "This can lead you to serious troubles with DOS leaks" , is there any better way ? – susant Nov 12 '14 at 07:20
  • @susant better way is to gather statistic about your traffic using diagnostic tools and analyze it from time to time. then you would be able to make more weightful descision about the values of the message sizes, buffer sizes, array length. – Alex Nov 12 '14 at 09:16
  • 3
    A quick way to remember: 2147483647 is the 8th Mersenne prime... :) – Sylvain Rodrigue Jun 23 '15 at 14:21