download of larger static file stops using wfastcgi and Flask on IIS10 and Windows Server 2019 RRS feed

  • Question

  • User-1178064118 posted

    After a day of trying all kinds of hints from the web I am out of ideas with this one: I have the simplest Flask app serving a static 600MB file to download. After about 1,5-2 minutes or about 80-280MB (so not at all after the same amount of bytes or seconds) the download stops and the client gets a HTTP 500 (according to the IIS log).

    • If I serve the same file from a static website (no python or flask at all involved) on that IIS, the download finishes.
    • Everything runs fine if I start flask on the same machine as a local server (and access it via localhost, of course.).
    • If I serve the same app on a second server running Windows Server 2012R2 and IIS 8.5, it works fine.
    • The wfastcgi log does not show any errors and flask does not throw any Exceptions.

    The code is rather trivial:


    def create_app():
      filename = inspect.getframeinfo(inspect.currentframe()).filename
      root_path = os.path.dirname(os.path.abspath(filename))
      app = Flask(__name__, root_path=root_path)
      return app
    app = create_app()
      def index():
      return render_template('index.html')

    index.html under templates:

        <a href="{{url_for("static", filename="bigfile.bin")}}"> Please download </a>
    • If have also tried to use flask's send_from_directory explicitly -> same difference.
    • I have set all timeouts I know of up to at least 5 minutes: Timeouts for the ApplicationPool, the connection timeout of the site and even the connection timeout under system.applicationHost/webLimits.There I have changed minBytesPerSecond to 0, as well.
    • The Webserver is an IIS 10 on Windows Server 2019 with wfastcgi installed.
      The issue occurs on HTTPS AND on HTTP. For https: Switching HTTP/2 on or off has not had an effect.
      I have used current Firefox, Chrome and iOS Safari on the client site, makes no difference.
    • Versions are:
      Python 3.6.4 (I have also tried 3.7.x)
      Flask 1.1.1
      Werkzeug 1.0.1
      wfastcgi 3.0.0.
      These are exactly the same versions as those on the older IIS 8.5 where it works.

    Any suggestions even as to how to debug where and why exactly the download fails (I am not even sure if flask is still involved at this point) would be highly appreciated. Neither the IIS logs nor the wfastcgi log give me any idea anymore.

    Thursday, April 2, 2020 6:11 PM


  • User-1178064118 posted

    Solved the problem using Failed Request Tracing, which creates the really useful logfiles. It turned out that there was another timeout to be set: Under IIS\FastCGI Settings. there is python as an application and "Edit" in the action pane leads to the setting RequestTimeout.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Friday, April 3, 2020 4:19 AM