ngx_http_discard_request_body may make keepalive connection hang in CLOSE_WAIT
I wonder if it's a bug. It confused me.
recv in ngx_http_discard_request_body return 0, but ignored(suppose to close
conntection soon). So the connection will stay in keepalive timer untill
timeout, while client already closed and server stay in CLOSE_WAIT.
nginx version: nginx/1.17.6
built by gcc 4.4.6 20110731 (Red Hat 4.4.6-4) (GCC)
built with OpenSSL 1.1.1c 28 May 2019
TLS SNI support enabled
configure arguments: --with-debug --prefix=/home/qspace/nginx --user=qspace
--group=users --with-http_ssl_module --with-http_v2_module
--with-openssl=../openssl-1.1.1c --with-pcre=../pcre-4.3 --with-stream
limit_conn_zone $binary_remote_addr zone=connperip:10m;
limit_conn connperip 1; (make it redirect to /503.html)
body not empty, i.e, content_len != 0
e.g. curl "http://127.0.0.1" -F "file=@some_file" (close conntection after
Re: ngx_http_discard_request_body may make keepalive connection hang in CLOSE_WAIT
> On 7 Jan 2020, at 19:12, ak638 <[hidden email]> wrote:
> I wonder if it's a bug. It confused me.
> recv in ngx_http_discard_request_body return 0, but ignored(suppose to close
> conntection soon). So the connection will stay in keepalive timer untill
> timeout, while client already closed and server stay in CLOSE_WAIT.
This is a known issue. It would be nice if
you could try and report back if this patch helped you.
# HG changeset patch
# User Sergey Kandaurov <[hidden email]>
# Date 1534236841 -10800
# Tue Aug 14 11:54:01 2018 +0300
# Node ID b71df78c7dd02f0adf817a5af1931e8e4e9365d0
# Parent 70c6b08973a02551612da4a4273757dc77c70ae2
Cancel keepalive and lingering close on EOF better.
Unlike in 75e908236701, which added the logic to ngx_http_finalize_request(),
this change moves it to a more generic routine ngx_http_finalize_connection()
to cover cases when a request is finalized with NGX_DONE.
In particular, this fixes unwanted connection transition into the keepalive
state after receiving EOF while discarding request body.