How to control keepalive connections for upstream before the version of 1.15.3

wu560130911 nginx-forum at forum.nginx.org
Wed Nov 20 02:48:23 UTC 2019


I'm use Nginx  proxy to tomcat, tomcat have two parameters manage keep
alive, first one is keepAliveTimeout : how the connection idle time; second
is maxKeepAliveRequests : how the connection reuse counts;

when use Nginx version before the version of 1.15.3, Nginx can't know when
tomcat will be close connection, so online have 502 error;

I'm analysis network packages, find have two reasons cause 502 error to
occur; but there have same root reason;

fist reason : tomcat keepalive time is arrived and close handle, but nginx
don't know that; cause recv() failed (104: Connection reset by peer) while
reading response header from upstream;

second reason : tomcat have send tcp fin package , but nginx also send
request to it; case upstream prematurely closed connection while reading
response header from upstream;

I have adjust the size of keepAliveTimeout, but the problem still occur,
because use nginx with version before 1.15.3;

how can I slove this problem?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,283137,286282#msg-286282



More information about the nginx mailing list