5

Here is the error log that I received when I put my application in the long run.

Oct 22 11:41:18 uwsgi[4613]: OSError: write error
Oct 22 11:41:48 uwsgi[4613]: Tue Oct 22 11:41:48 2019 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 341] during GET /api/events/system-alarms/ 
Nov 19 19:11:01 uwsgi[30627]: OSError: write error
Nov 19 19:11:02 uwsgi[30627]: Tue Nov 19 19:11:02 2019 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during GET /api/statistics/connected-clients/?type=auto&required_fields=0,11 

Also, I need to know the reason for the os write error and a broken pipe in detail.

Usman Maqbool
  • 3,351
  • 10
  • 31
  • 48
Dharshini
  • 77
  • 1
  • 5
  • Possible duplicate of [uwsgi IOError: write error](https://stackoverflow.com/questions/34768527/uwsgi-ioerror-write-error) – Linh Nguyen Nov 25 '19 at 07:33

2 Answers2

6

Faced a similar issue before, it happens when the client makes a request and then closes it (either because server took too long to respond or client has been disrupted) but uwsgi is still processing that request.

From the Tags I notice that you are using nginx+uwsgi configuration, there are multiple ways to solve this :

  • Find your most time consuming request and match it between nginx and uwsgi(harakiri). Note that this doesn't work when client itself disrupts.
  • On your nginx config set uwsgi_ignore_client_abort on for uwsgi routes.
  • Or you can just disable logging of write errors ignore-write-errors = true.
Pavan Skipo
  • 1,757
  • 12
  • 29
2

In my experience these are legitimate disconnections, where the HTTP client (the browser) closes the connection and Nginx in turn closes the file descriptor uWSGI is writing a response to.

I can reliably replicate the issue by visiting any non-trivial Django page and hammering on the F5 (refresh) key a few times rapidly. That suggests that the errors are part of normal operation and aren't causing any negative user experience, so are likely safe to ignore.

To hide these exceptions in the logs you need all three of the following uWSGI settings:

ignore-sigpipe
ignore-write-errors
disable-write-exception

The each correspond to one of the following error lines:

mysite - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request / (ip 1.2.3.4) !!!
mysite - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during GET / (1.2.3.4)
OSError: write error

The disable-write-errors option will also prevent the errors being sent to a tool like Sentry if you're using something like that.

Ben Sturmfels
  • 1,303
  • 13
  • 22