Error response body not sent if upload is incomplete

Maxim Dounin mdounin at mdounin.ru
Mon Jan 1 20:34:49 UTC 2018


Hello!

On Sat, Dec 30, 2017 at 06:04:26PM -0500, naktinis wrote:

> Find the server logs below. It does seem to match what you've quoted.
> 
> Do you think the upstream server (uwsgi) is the one not returning the body?
> 
> I was able to fix this by consuming the request body in my application
> before returning the response. However, I'm still wondering how nginx is
> supposed to behave in such situations.
> 
> Log for the request with the larger file:
> api-server_1   | [pid: 21|app: 0|req: 1/1] 172.19.0.1 () {38 vars in 601
> bytes} [Sat Dec 30 11:14:46 2017] POST / => generated 54 bytes in 2 msecs
> (HTTP/1.1 403) 2 headers in 78 bytes (1 switches on core 0)
> api-server_1   | 2017/12/30 11:14:46 [error] 12#12: *1 readv() failed (104:
> Connection reset by peer) while reading upstream, client: 172.19.0.1,
> server: , request: "POST / HTTP/1.1", upstream:
> "uwsgi://unix:///tmp/uwsgi.sock:", host: "0.0.0.0:5000"
> api-server_1   | 172.19.0.1 - - [30/Dec/2017:11:14:46 +0000] "POST /
> HTTP/1.1" 403 25 "-" "curl/7.55.1" "-"
> 
> With the smaller file:
> api-server_1   | 172.19.0.1 - - [30/Dec/2017:11:15:41 +0000] "POST /
> HTTP/1.1" 403 79 "-" "curl/7.55.1" "-"
> api-server_1   | [pid: 20|app: 0|req: 3/4] 172.19.0.1 () {38 vars in 595
> bytes} [Sat Dec 30 11:15:41 2017] POST / => generated 54 bytes in 1 msecs
> (HTTP/1.1 403) 2 headers in 78 bytes (1 switches on core 0)

The "readv() failed (104: Connection reset by peer)" error 
indicate that there is a backend problem which makes it impossible 
to reliably receive the body of the response.  To make it possible 
for nginx to receive the body, backend must either read the whole 
body, or implement proper connection teardown (in nginx, this is 
called lingering_close, see http://nginx.org/r/lingering_close).

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list