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).
The code is rather trivial:
__init_.py:
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()
@app.route("/")
def index():
return render_template('index.html')
index.html under templates:
<html>
<body>
<a href="{{url_for("static", filename="bigfile.bin")}}"> Please download </a>
</body>
</html>
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.
Changing the OS is not an option here, changing the webserver would at least be a huge pain.
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.
C.Nivs pointed me in the right direction. Thanks a bunch.
Should others run into similar problems, here is how I solved it: I had to install Failed Request Tracing in IIS first. There is a good description on how to use it here: https://learn.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis-85.
It revealed that the request failed due to a FASTCGI_REQUEST_TIMEOUT. So there is yet another timeout in IIS to attend to: It is under IIS\Fast CGI Settings and there under python.exe->Edit. Setting the RequestTimeout up solved my problem.