iisconnection-timeoutbad-gatewaywaitresshttpplatformhandler

Bad Gateway = Timeout from IIS Platform with python waitress


I'm getting a bad gateway due to a timeout of 2 minutes but I don't now how to configure it, the following is what I have tried.

So, first of all, in python I'm setting a 120 second timeout (I don't want to change this, I've tried with 115 seconds and it works but I want to resolve the external timeout from IIS or waitress, I don't want to change this limit in my internal software).

try:
    # ...
    req = http.request("POST", url = url, timeout=120, body = body, headers=headers)
    # ...
except urllib3.exceptions.RequestError as exc:
    log.error("reporting exc type %s message %s", type(exc), exc)
    return render_template_string("External API is not responding")

I've set this in Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <httpRuntime executionTimeout="200" />
    </system.web>
  <system.webServer>
  <handlers>
      <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
    </handlers>
    <httpPlatform

etc...

and in my waitress batch:

F:
cd F:\Appl\flask
venv\scripts\waitress-serve.exe --channel-timeout=300 --host=127.0.0.1 --port=%1 sample00:app

And from IIS Configure > Limits I've set "Connection time-out (in seconds):" 200


Solution

  • Finally solved by adding requestTimeout="00:05:00" in the httpPlatform tag of the web.config