You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Tankelevich Leonid <Le...@comverse.com> on 2007/06/21 09:18:53 UTC

HTTP 1.1 persistence duration

Hello team,

As I understood, physical connection remains open (and may be reused for
the next request) during some time after response to a HTTP 1.1 request.
Is this duration controlled by server or client?
How may I manage it with HttpClient?

Thanks,
Leonid Tankelevich
Comverse Ltd.

RE: HTTP 1.1 persistence duration

Posted by Tankelevich Leonid <Le...@comverse.com>.
Thanks a lot!
L. 

-----Original Message-----
From: Oleg Kalnichevski [mailto:olegk@apache.org] 
Sent: Thursday, June 21, 2007 12:03
To: HttpClient User Discussion
Subject: RE: HTTP 1.1 persistence duration

On Thu, 2007-06-21 at 11:58 +0300, Tankelevich Leonid wrote:
> Thanks Oleg,
> 
> Do you know how long servers do typically keep the connection alive?
> 
> Thank you,
> L.
> 

Apache HTTPD shipped with Ubuntu 7.04 has KeepAliveTimeout set to 15 sec
per default. This value may very across distributions, platforms, and
HTTP server implementations.  

#
# KeepAliveTimeout: Number of seconds to wait for the next request from
the # same client on the same connection.
#
KeepAliveTimeout 15

Oleg

> -----Original Message-----
> From: Oleg Kalnichevski [mailto:olegk@apache.org]
> Sent: Thursday, June 21, 2007 11:39
> To: HttpClient User Discussion
> Subject: Re: HTTP 1.1 persistence duration
> 
> On Thu, 2007-06-21 at 10:18 +0300, Tankelevich Leonid wrote: 
> > Hello team,
> > 
> > As I understood, physical connection remains open (and may be reused

> > for the next request) during some time after response to a HTTP 1.1
> request.
> > Is this duration controlled by server or client?
> > How may I manage it with HttpClient?
> > 
> 
> The HTTP spec does not prescribe how long a persistent connection may 
> be kept alive. Essentially a persistent connection can be closed by 
> either client or server at any time of their choosing. HttpClient 
> keeps persistent connections alive infinitely per default. One can 
> implement a custom connection eviction policy by using 
> #closeIdleConnections method of the HttpConnectionManager interface. 
> There is also a utility class called IdleConnectionTimeoutThread [2] 
> which can be used to start a background thread to periodically invoke 
> #closeIdleConnections() on connection manager instances registered
with the thread.
> 
> Hope this helps
> 
> Oleg
> 
> [1]
> http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/common
> s/
> httpclient/HttpConnectionManager.html#closeIdleConnections(long)
> [2]
> http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/common
> s/ httpclient/util/IdleConnectionTimeoutThread.html
> 
> > Thanks,
> > Leonid Tankelevich
> > Comverse Ltd.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> httpclient-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> httpclient-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


RE: HTTP 1.1 persistence duration

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2007-06-21 at 11:58 +0300, Tankelevich Leonid wrote:
> Thanks Oleg,
> 
> Do you know how long servers do typically keep the connection alive?
> 
> Thank you,
> L.
> 

Apache HTTPD shipped with Ubuntu 7.04 has KeepAliveTimeout set to 15 sec
per default. This value may very across distributions, platforms, and
HTTP server implementations.  

#
# KeepAliveTimeout: Number of seconds to wait for the next request from
the
# same client on the same connection.
#
KeepAliveTimeout 15

Oleg

> -----Original Message-----
> From: Oleg Kalnichevski [mailto:olegk@apache.org] 
> Sent: Thursday, June 21, 2007 11:39
> To: HttpClient User Discussion
> Subject: Re: HTTP 1.1 persistence duration
> 
> On Thu, 2007-06-21 at 10:18 +0300, Tankelevich Leonid wrote: 
> > Hello team,
> > 
> > As I understood, physical connection remains open (and may be reused 
> > for the next request) during some time after response to a HTTP 1.1
> request.
> > Is this duration controlled by server or client?
> > How may I manage it with HttpClient?
> > 
> 
> The HTTP spec does not prescribe how long a persistent connection may be
> kept alive. Essentially a persistent connection can be closed by either
> client or server at any time of their choosing. HttpClient keeps
> persistent connections alive infinitely per default. One can implement a
> custom connection eviction policy by using #closeIdleConnections method
> of the HttpConnectionManager interface. There is also a utility class
> called IdleConnectionTimeoutThread [2] which can be used to start a
> background thread to periodically invoke #closeIdleConnections() on
> connection manager instances registered with the thread.
> 
> Hope this helps
> 
> Oleg
> 
> [1]
> http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/
> httpclient/HttpConnectionManager.html#closeIdleConnections(long)
> [2]
> http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/
> httpclient/util/IdleConnectionTimeoutThread.html
> 
> > Thanks,
> > Leonid Tankelevich
> > Comverse Ltd.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


RE: HTTP 1.1 persistence duration

Posted by Tankelevich Leonid <Le...@comverse.com>.
Thanks Oleg,

Do you know how long servers do typically keep the connection alive?

Thank you,
L.

-----Original Message-----
From: Oleg Kalnichevski [mailto:olegk@apache.org] 
Sent: Thursday, June 21, 2007 11:39
To: HttpClient User Discussion
Subject: Re: HTTP 1.1 persistence duration

On Thu, 2007-06-21 at 10:18 +0300, Tankelevich Leonid wrote: 
> Hello team,
> 
> As I understood, physical connection remains open (and may be reused 
> for the next request) during some time after response to a HTTP 1.1
request.
> Is this duration controlled by server or client?
> How may I manage it with HttpClient?
> 

The HTTP spec does not prescribe how long a persistent connection may be
kept alive. Essentially a persistent connection can be closed by either
client or server at any time of their choosing. HttpClient keeps
persistent connections alive infinitely per default. One can implement a
custom connection eviction policy by using #closeIdleConnections method
of the HttpConnectionManager interface. There is also a utility class
called IdleConnectionTimeoutThread [2] which can be used to start a
background thread to periodically invoke #closeIdleConnections() on
connection manager instances registered with the thread.

Hope this helps

Oleg

[1]
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/
httpclient/HttpConnectionManager.html#closeIdleConnections(long)
[2]
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/
httpclient/util/IdleConnectionTimeoutThread.html

> Thanks,
> Leonid Tankelevich
> Comverse Ltd.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: HTTP 1.1 persistence duration

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2007-06-21 at 10:18 +0300, Tankelevich Leonid wrote: 
> Hello team,
> 
> As I understood, physical connection remains open (and may be reused for
> the next request) during some time after response to a HTTP 1.1 request.
> Is this duration controlled by server or client?
> How may I manage it with HttpClient?
> 

The HTTP spec does not prescribe how long a persistent connection may be
kept alive. Essentially a persistent connection can be closed by either
client or server at any time of their choosing. HttpClient keeps
persistent connections alive infinitely per default. One can implement a
custom connection eviction policy by using #closeIdleConnections method
of the HttpConnectionManager interface. There is also a utility class
called IdleConnectionTimeoutThread [2] which can be used to start a
background thread to periodically invoke #closeIdleConnections() on
connection manager instances registered with the thread.

Hope this helps

Oleg

[1]
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/HttpConnectionManager.html#closeIdleConnections(long)
[2]
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/util/IdleConnectionTimeoutThread.html

> Thanks,
> Leonid Tankelevich
> Comverse Ltd.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org