Forums

"IOError: write error", "SIGPIPE" and "uwsgi_response_writev_headers_and_body_do" error

Hello all, I have created a webhook on server which was running fine up to last week but then recently it is generating many errors. Although, no major changes were done in code.

The server.log reflects below error while error.log has "IOError: write error" at same time.

2018-11-15 03:49:16 Thu Nov 15 03:49:16 2018 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /webhook (ip 10.0.0.117) !!!
2018-11-15 03:49:16 Thu Nov 15 03:49:16 2018 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during POST /webhook (10.0.0.117)
2018-11-15 04:06:44 Thu Nov 15 04:06:44 2018 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /webhook (ip 10.0.0.117) !!!
2018-11-15 04:06:44 Thu Nov 15 04:06:44 2018 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during POST /webhook (10.0.0.117)
2018-11-15 05:06:45 Thu Nov 15 05:06:45 2018 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /webhook (ip 10.0.0.117) !!!
2018-11-15 05:06:45 Thu Nov 15 05:06:45 2018 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during POST /webhook (10.0.0.117)

Can anyone help to figure what could be causing this?

Do you have any endpoints that take a long time to run? (eg: the /webhook endpoint). If it takes more than 5min, then pythonanywhere will cut it off. It is also possible that whatever you were using to connect to your pythonanywhere endpoint has an even more aggressive cut off, and so just disconnected say 30 seconds in. This is because we all expect http requests to have a processed response say at a maximum in a couple seconds.

I'm experiencing the same issue. When I do a test on my local development environment (simulating slow connection) it works fine.

Could this have anything to do with the webserver in combination with wsgi settings?

Could you give some more details? Is your site generating SIGPIPE errors for every request? Or just for some? How long do the requests take to process?

Hello dmenis, In my case issue was with the HTTP request I was making.

It is also possible that whatever you were using to connect to your pythonanywhere endpoint has an even more aggressive cut off, and so just disconnected say 30 seconds in. This is because we all expect http requests to have a processed response say at a maximum in a couple seconds.

As the Staff has pointed out, I looked deeper and found that the API which I was calling had changed and it used to take minutes sometimes to respond. So, it was not actually anything wrong with PythonAnywhere but the API I was invoking.

I get the error when uploading files Upload is made using a Django 1.11 model and basically letting standard Django handle the upload process.

When using files the size of +/- 10Mb there is no problem but when with a 144Mb file it fails every time at about the 12% or sometimes I see that the upload restart (to 0%) and then fails again after a few % uploaded. In the error log I see: "IOError: write error" In the server log I see: "SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request / (ip 10.0.0.162) !!!" and "uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during GET / (10.0.0.162)"

When I test using my local dev environment and simulating a slow connection the upload of the 144Mb file works fine. This let's me to conclude that it probably is some server setting.

Any idea what it might be?

I think you're hitting our upload file size limit -- it's 100MiB.

Thanks for the response.

Can this be changed ?

Our app let's user upload, relatively, small 360 videos. Although they are short videos (fixed point 360 video) they tend to be between 150 and 300 Mb.

PS: it is only a small group of users that can do this those who create our interactive stories.

Unfortunately it can't be changed right now :-(

Does this mean there is no way for my Django app to upload file that are larger than 100Mb ?

Unfortunately there isn't, no.

Thank for you answer this puts us in an awkward position

We will either need to host our app elsewhere or host are media files elsewhere Not sure yet what we will do as our experience with PythonAnywhere has been good.

Will keep you posted :-)

I am having similar error as well ---> 2021-01-08 19:18:10 Fri Jan 8 19:18:10 2021 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /_dash-update-component (ip 10.0.0.124) !!!

I would like to know if there is a workaround please

Is this for a request that takes more than five minute to process? Or are you just getting errors like that every now and then in your logs?

The error message just means that while your code was trying to send a response back to a client browser, the client closed the connection. This can happen if a request times out (for example if it takes more than five minutes), but it can also happen if the browser connecting to your site loses its connection. So you will get some errors like that in your logs just as a result of people using unreliable connections to access it -- for example, if they're using their cellphone and they drop out of coverage in between sending you a request and you sending back the response. So occasional errors like that are unavoidable. It's only a problem if you keep getting them all of the time, or if a particular URL on your site always generates that error.

Hello, so I'm also encountering similar problem while running my website. I hit API from my website and it will run a loop for 15 iterations, and then the web will display the processed data from the API. The data will be sent to MySQL database before displayed on the web. But I always get this message on my server logs when I hit the API and the error page is also appearing on my site, though all the data from 15 iterations are successfully transferred to the database.

SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /single_testing (ip 10.0.0.66) !!! 
 uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during POST /single_testing (10.0.0.66)

But when I change the iteration on my API to 9 or 10 iteration, my website runs fine without showing the error page. Can anyone please help me fix this? Thank you

That message means that the client disconnected before the response has been effectively sent back. It's not necessarily an error, rather a symptom. If you don't want to see such messages in the logs, you may try to make processing in your app shorter (if they are caused by a short timeout on the client side) , but you can always get such message from time to time if the client disconnects.

Hello I'm having the same issue, My application was running ok, but since yestarday it has been throwing this error. No changes have been made to any part of the code

It means that your site is running slowly; perhaps you're getting more traffic than usual, or the amount of data that it's processing has increased so that your code runs more slowly? Check out this help page for website performance optimisation tips.

Thank's... But the thing is that my application is running slower every day on the pythonanywhere side. Couple of weeks ago it was taken abput 30 seconds to run, then it increased to 50 seconds and today is 1 minute and 40 seconds. I haven't done any change on it, I increased the number of workers on my plan, but still taking to long to run

Do you know which part in your code is running slower? Is it some computation? database query? call to external service?

It's computation, pure CPU time. It's a call to a tensorflow

That would probably be best done asynchronously outside of the web app: https://help.pythonanywhere.com/pages/AsyncInWebApps/