3
votes

I have my app.config file set up so that the maxRecievedMessageSize is well beyond 65536, any tips I can get in order to improve this?

This is my current app.config file

<bindings>
  <basicHttpBinding>
    <binding
     name="FinalInspectionEndpoint"
     maxBufferSize="2147483647"
     maxReceivedMessageSize="2147483647" >
      <security mode="None" />
      <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
    </binding>
  </basicHttpBinding>
</bindings>


<services>
  <service name="AGY.FI.SQLService.FinalInspectionManager">
    <endpoint address="" binding="basicHttpBinding" contract="AGY.FI.SQLService.FinalInspectionService" bindingConfiguration="FinalInspectionEndpoint">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"  />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8732/Design_Time_Addresses/AGY.FI.SQLService/Service1/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- 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>

2

2 Answers

1
votes

The config file looks like it's set up correctly.

Are you still getting an error, or simply asking if there's a better way to do what you're doing? Is it possible the size of the message is larger than the value you have currently set?

If the former, what is the error you're seeeing?

If the latter, the only thing I would recommend is to set the size of maxReceivedMessageSize to a value that is as large as the largest value you expect the service to need, so you limit your exposure to DDOS attacks.

0
votes

You did not tell us, what you are sending when this exception is thrown. From my experience, this happened when I was serializing whole objects which contained a lot of properites or even collections.

One way around is to make buffer on each side and serialize object, break up result of serialization to smaller pieces, send pieces one by one, and then have them put togather on other side and deserialize. At least this solved my problem with this exception.