Skip to content
Tags

IIS’s ARR and the ProtocolException: “The number of bytes available is inconsistent with the HTTP Content-Length header….”

September 16, 2012

This is a quick synopsis aimed at getting you quickly focused on a likely, but non-obvious, source of this exception.  Hopefully, you’ll avoid spending hours poring through WCF Service Trace Viewer logs, application logs, etc.

You are using IIS’s ARR (Application Request Routing) and get a SystemServiceModel.ProtocolException.  The exception message is:

“The number of bytes available is inconsistent with the HTTP Content-Length header.  There may have been a network error or the client may be sending invalid requests”.

These exceptions are likely to be intermittent.  Check the following to quickly find the cause of the problem:

  1. The Wcf Service Trace Viewer may or may not show the above exception.
  2. Fiddler2 will most likely show Error 502, Bad Gateway.
  3. In the IIS Manager, look at the ARR configuration icons in the Server Farm that is created when ARR is created.  Open the Proxy configuration icon.  What is the Timeout value for the proxy?
    1. Having too short a value for the Timeout will cause this error.
    2. The error will happen on Wcf service operations whose elapsed time is longer than this Timeout value.  Thus, the ARR proxy will throw an exception on exceeding the Timeout, and cause the SystemServiceModel.ProtocolException while a long running Wcf service operation is in progress, running along alive and well.
    3. You can experiment changing this timeout value.  Does the exception stop when you increase the Timeout value by a factor of 10 or 100?  Does the exception become non-intermittent when you decrease the Timeout value by 50% to 80%?  If so, then this is the likely culprit.  You’ll have to adjust the Timeout value so that it allows your longest running WCF service operation to complete.

To learn more about ARR see http://www.iis.net/downloads/microsoft/application-request-routing

Advertisements

From → Uncategorized, WCF

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: