3

My question is very similar to uWSGI raises OSError: write error during large request

I have a python flask app running on EC2.
To enable download of files from the UI interface (by clicking a button), I run this on ec2:

    uwsgi --socket 0.0.0.0:8000 --protocol=http -w wsgi:application  -z 120 --http-timeout 120 --enable-threads -H /home/test/env --daemonize /home/test/test.log

and the UI becomes operational. When i click the download button certain computations take place before the csv becomes ready to download. I don't have a uwsgi.ini file or any kind of nginx.

9/10 files download fine, but some files while trying to download throw this in the log:

Wed May  5 18:26:01 2021 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /abc/jobid (ip xx.xx.xv.redacted_ip) !!!  
  
Wed May  5 18:26:01 2021 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 341] during  
 GET /abc/jobid (xx.xx.xv.redacted_ip)
OSError: write error

and the F12 on Web UI shows

main.js:678 GET https://my_api_url/jobid 504 (Gateway Timeout)
main.js:678 Uncaught (in promise) Error: Request failed with status code 504
    at e.exports (main.js:678)
    at e.exports (main.js:993)
    at XMLHttpRequest.d.onreadystatechange (main.js:678)

I'm already using the -z 120 and the --http-timeout 120 options but doesn't seem to be making a difference https://stackoverflow.com/a/28458462/4590025.

I also looked at https://stackoverflow.com/a/63109495/4590025 but it is not clear where/how to try it as

How do I debug this further?

DJ_Stuffy_K
  • 615
  • 2
  • 11
  • 29

1 Answers1

0

I have had a similar problem and was able so solve it by adding the following to my nginx.conf:

http {
    uwsgi_connect_timeout   3600s;
    uwsgi_read_timeout      3600s;
    uwsgi_send_timeout      3600s;
}

Which increases the allowed timeout to 1 hour, I would suggest choosing a far lower value. I found the solution in a related question: https://stackoverflow.com/a/59286362/7924573

tschomacker
  • 631
  • 10
  • 18