Question

Ok I'm trying to solve the "he maximum string content length quota (8192)" issue and I see the answer in this post:

The maximum string content length quota (8192) has been exceeded while reading XML data

I don't want to go monkey-ing around with the config on my production server (serious case of fat fingers) so I copy the code and config to my local machine do a test run with the original config and.... don't get the problem, so cant test that my new config will fix the problem.... grrr.

Where do the default readerQuotas values get set?

I've checked under %\Microsoft.NET\Framework64\v4.0.30319\Config in both machine.config and web.config. can cant see anything that looks right. any help?

Just to reiterate, I'm trying to replicate this issue locally. any help in breaking my machine would be appreciated.

Was it helpful?

Solution

Thanks for the help guys. You were however giving me ways to fix the problem, not how to replicate it, my problem was that I WASN'T getting the issue locally and wanted to work out why, so I could then fiddle with my config and be certain all my tests etc ran before deploying config changes to my live server. But in the end the solution was a little different to your suggestions. I am using the simplified wcf configuration:

<behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

which I liked because I had quite a few services running out this project and didn't want to have to wire them all up individually.

when I started examining the difference between my local machine (on which the same compiled dlls/config worked) and the prod machine (where they didn't work) the difference was.....

...I had .net 4.5 installed locally, but not on my prod server. Installing seems to have updated the default values used and my service now works (with the original configuration)

Again thanks for helping.

OTHER TIPS

short answer is, just keep your reader quota under your concerned binding this way (also increase maxReceivedMessageSize under binding node), and you can be rest assured that this error won't come on production. It should handle any size of message in real world, but you shall limit numbers per size limitation needed per your wcf design.

      <binding name="BindingForBiggerMessages"
      maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647"
         maxStringContentLength="2147483647"
         maxArrayLength="2147483647"
         maxBytesPerRead="2147483647"
         maxNameTableCharCount="2147483647" />
    </binding>

Also make sure changes you make at wcf end's config, are also done at client app side's config too, else will not work.

In detail:---------------------------

This is just to cover how to replicate this issue in local, which is really not needed as it's well known error in wcf community and has working solution to it, which already shared above

I feel "Secret Squirrel" link should help in fixing this, still if you have not got it working, then please read this, it will give clear idea about what those keys are under reader quota:

http://lucvknet.blogspot.com/2010/09/when-wcf-blows-whistle-part1.html

I guess key you need to concentrate on is MaxStringContentLength. Actually client of your production app is sending message to wcf, which has more than 8192 characters in one of it's field/property (assuming per your production issue description).

See in your wcf config (production copy which you are running locally), if MaxStringContentLength is defined/configured under your binding (binding which is breaking for large messages/objects), if it's not defined then define it with value less than number of characters, you want to test with for a given field in your message (to break).

So if you want your wcf to break for message having one element/field with more than 8192 characters, then keep it lesser than 8192, and then invoke wcf with object (parameter to wcf method) with a string field/member having more than 8192 characters in it, then it should break.

Note: If you see that MaxStringContentLength is already defined to 8192 in your config, still you are not getting issue with large message/data, then make sure message is having one field with value set such that it's crossing the character limit set by MaxStringContentLength)

If breaks and you get same error as production application is getting, then just configure it to a higher value.

Note: If you don't see these keys defined in your wcf binding, then wcf will use default values for these quota as they are not defined by you, so to replicate issue start first with defining one yourself to override any default setting done.

Try this

<system.serviceModel>
<bindings>
  <basicHttpBinding>
     <binding name="BindingName" maxReceivedMessageSize="10000000">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/>
     </binding>
 </basicHttpBinding>
</bindings>
</system.serviceModel> 

You have to set the quotas on the server and client. If you mis one of them you still get this error.

<readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top