I have an API written in Python which I am accessing with IIS 7.5 via the ISAPI extension PyISAPIe. I thought it would be sensible to separate this API from our main site, so it is in a different site accessed with port 8008.

To be able to access the API with URL like http://domain/api, I have created a reverse proxy rule in IIS with ARR and URL Rewrite so that http://domain/api is redirected to http://domain:8008.

The reverse proxy seems working correctly and I am receiving the correct responses from the API in most cases (the API returns JSON). However, in some cases, I am getting 502 errors with the following message:

502 - Web server received an invalid response while acting as a gateway or proxy server.

This seems to be happening only when the JSON response is above a certain size (about 125KB in my tests) - for smaller sizes, everything seems to be working correctly.

I've tried increasing the Response buffer threshold in the proxy settings to no effect.

Addtional Information

In the logs I can see that the requests to the site on port 8008 are succeeding and are returning a 200 status code.

After activating Failed Request Tracing, the only error/warning is the following (this is after recieving the response from the other site - see previous point) :

Warning ModuleName="ApplicationRequestRouting",
Notification="EXECUTE_REQUEST_HANDLER", HttpStatus="502", 
HttpReason="Bad Gateway", HttpSubStatus="3",
  • Trying enabling Failed Request Tracing for 502 error code and collect more information about what is failing. – Giovanni Tirloni Sep 1 '14 at 18:39

You need to increase the maxJsonLength setting in web.config. See this question on SO for details on allowed values and troubleshooting.

  • Isn't that for ASP.NET? It's not having an effect in any case. – Tom--G Sep 2 '14 at 10:40

Can you attach the request traces from ARR (the 502) and from the site (the 200)? I had a similar problem in the past and I think I resolved it by increasing the maxRequestLength in the config of the ARR and site that is being rewritten.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.