Hi Christopher, We actually found what was the problem with keep-alive. It is caused by the fact that Tomcat didn’t specify parameters ‘Keep-Alive: timeout=60,max=100’, in HTTP header. In this case Java uses parameters by default, ie ‘Keep-Alive: timeout=0,max=5’ and that is why connection been closed by the client immediately.
Please advise if it is possible to configure tomcat to set in Http response header parameters ‘Keep-Alive: timeout=60,max=100’? Currently I’ve set parameters ‘keepAliveTimeout="60000", maxKeepAliveRequests = "100"’ for tomcat connector but response header still does not contain these values. BR, Maxim From: Christopher Schultz Reply-To: Tomcat Users List Date: Saturday 13 June 2015 02:17 To: Tomcat Users List Subject: Re: TCP connections reuse -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Andy, On 6/12/15 12:35 PM, Wang, Andy wrote: > Could this be as simple as the default keepaliveTimeout = 20000 > (i.e. 20s) This could certainly be the issue. Maxim, what does the timing look like with these events? 1. First HTTP request made 2. Connection is dropped 3. Second HTTP request is made (on a new connection) When do those things happen? You said you had protocol traces of everything. If #2 happens 20 seconds after #1, then I think you have your answer. - -chris > ________________________________________ From: Andy Wang > [aw...@ptc.com] Sent: Friday, June 12, 2015 11:31 AM To: Tomcat > Users List Subject: Re: TCP connections reuse > > Could this be as simple as the default keepaliveTimeout = 15000 > (i.e. 15s) > > Andy > > On 06/12/2015 11:20 AM, Christopher Schultz wrote: Maxim, > > On 6/12/15 1:53 AM, Maxim Neshcheret wrote: >>>> According to >>>> http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-keep ali > >>>> ve.html >>>> >>>> > connections in HTTP 1.1 >>>> <http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-kee pal > >>>> ive.html%20connections%20in%20HTTP%201.1> >>>> >>>> > are persistent by default. >>>> >>>> But if it is incorrect behavior in Java then maybe there is >>>> some way or configuration in Tomcat to put Keep-alive >>>> parameter in the response header? >>>> >>>> I do call HttpURLConnection.disconnect() only when client is >>>> stopped. Keep-alive is used for sure. > > I would expect the connection to be kept open unless you call > disconnect. But you are creating a new HttpURLConnection each time > and then discarding it. I'm not sure how the connection pooling > works under the hood within the JVM. It used to be difficult to get > the JVM to release a connection and actually terminate the TCP/IP > connection. > > http://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepali ve > > .html > > Pay close attention to the remarks about stream-handling. > > Tomcat may close the connection under certain circumstances, > usually error-related. If you are getting 200 OK responses from > Tomcat, then I'm not sure why the TCP/IP connection would be > dropped, unless Java thinks that 30 seconds is too long of an idle > time to keep those connections open. > > Thanks, -chris >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org >> > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIcBAEBCAAGBQJVezA+AAoJEBzwKT+lPKRYV6QP/RvmRCvEdPszj9KriN6P+6ab B5sqrB5mlNtfxvyv8k33EtJf3l6h/tQDYE2eOCN4MvKRAGf7XdhA7udYxXUYBDRQ vhHPoUIhqP32RmQwEBnB3i47xASHDg1G1F7Ttqw6wL9p48APr5IlIs47Pr61en0n 11pHTt+25bGr36NgK0UlIIzJzEpH/HYikLS/wfqYNoVXn7RczkzKDrxg0xwZRgbg TacT4zz1noCaNPOqM1Jjdn+7Ilq+fPabhW8cOXPhkBU0RCE58HdwQ5Fu8BEPx5Sp 6qFmjtAEsTEGHHSin10/6GFA6EAypDQXRTulFQpq5eIZLNSl+l7EeFfE98n4Qyqj xrNeXKX06qdPO0gzjA0Q064vu2ZFSSIDFp6/zGtMqLhPhbPPTS5A6zpvXOJcfW28 k6b+mdOVGSiJ8zjz1NgsRtqtbwm1+y+Uh/UPdMDf7KhmS2EtxDtw4h8JYvKprkeQ Jwgh99Qu1a/hAmSRmRXjmlaC1RRXlMJcoHezHAicvRlwv0fko7/p5aqhK5nbogO+ aZV3GbaGmwWtp6JN2oCK4PdoQfgQS6nUYMmWoIHHSd1lTs8TQranG6M/bITNFinM vcUUZn6cqy6o+X4E/wz1x0CMiUoVlGIJeZevq65lhiaEXL3I2NMpeJtqpNP3cIof y4Cg/KPPs/B8TfnLM9WP =bGdd -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org