104: Connection reset by peer: nginx + rainbows + more than 1 MB downloads

I am running Rainpows ThreadPool + nginx (unix socket)

On large file downloads, I get the following in the nginx error log (nothing in the application log):

readv() failed (104: Connection reset by peer) while reading upstream 

The browser receives a response:

 413 Request Entity Too Large 

Why is this happening?

  • "client_max_body_size 80M;" installed both at the http level and on the server (just in case) in nginx
  • nginx communicates with rainbows through a unix socket (upstream socket + location @proxy_pass)
  • I do not see anything in other magazines. I checked:
    • rainbows magazine
    • magazine magazine
    • application log
    • dmesg and / var / log / messages
  • This happens when uploading a file ~> 1 MB in size
+4
source share
3 answers

It turns out that Rainbows had a client_max_body_size configuration client_max_body_size , which by default was 1 MB. The option is documented here.

If these options are enabled, Rainbows will 413 execute large requests silently. You may not know that this breaks down unless you run something in front of it.

 Rainbows! do # let nginx handle max body size client_max_body_size nil end 
+1
source

The error ECONNRESET (Connection reset by peer) means that the connection was dirty closed with the backend application. This usually happens if the backend application dies, for example. due to a segmentation error or killed by an OOM killer . To find out the exact reason, you should examine your backend logs (if any) and / or system logs.

+1
source

Perhaps you have client_max_body_size installed in your nginx.conf , which limits the body size to 1 MB, for example.

 client_max_body_size 1M; 

In this case, you need to delete it to allow downloading files with more than 1M.

+1
source

Source: https://habr.com/ru/post/1442774/


All Articles