hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Connection tmeout for objPost / objGet?
Date Fri, 30 Mar 2007 13:06:36 GMT
On Fri, 2007-03-30 at 05:09 -0700, Robert Bowen wrote:
> Hi,
>  
>   
>  
> I have a servlet using 1 instance of 
> httpclient (shared for all servlet threads), and using a 
> MultithreadedConnectionManager:
>  
>   
>  
> MultiThreadedHttpConnectionManager 
> mhcm = new MultiThreadedHttpConnectionManager();
>  
> mhcm.getParams().setMaxTotalConnections(maxConnections);
>  
> mhcm.getParams().setStaleCheckingEnabled(true);
>  
>   
>  
> HttpClient objHttp = new 
> HttpClient(mhcm);
>  
> objHttp.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
>  
>   
>  
>   
>  
> But every time I send a request, 
> depending on the destination, I'll have different connection and response 
> timeouts.
>  
>   
>  
> With response timeout everything 
> works fine because I use the following:
>  
>   
>  
> if (condition == 0) 
> objPost.getParams().setSoTimeout(responseTimeout0); 
> 
>  
> else if (condition == 1) 
> objPost.getParams().setSoTimeout(responseTimeout1); 
> 
>  
> else if (condition == 2) 
> objPost.getParams().setSoTimeout(responseTimeout2);
>  
>   
>  
> But what's the story with connection 
> timeout? I don`t have any method to set it in the Post method. The only way to 
> set a connection timeout 
>  
> is at the httpConnectionManager level 
> using:
>  
>   
>  
> objHttp.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
>  
>   
>  
> But that's not useful for me, 
> because this timeout is applied to ALL http connections, and I need to apply 
> different connection timeouts
>  
> depending on the variable 
> "condition". I need something like this:
>  

Bob,

It is up to a particular HTTP connection manager implementation to
decide whether a new connection needs to established or an existing one
can be re-used. Therefore the connect timeout value is only applicable
at the HTTP connection manager level. 

Oleg

>   
>  
> if (condition == 0) 
> 
>  
> {
>  
>  objPost.getParams().setSoTimeout(responseTimeout0); 
> 
>  
>  objPost.getParams().setConnectionTimeout(connectionTimeout0); 
> ?????????
>  
> }
>  
> else if (bla bla bla) 
> (....)
>  
>   
>  
>   
>  
> Is there any way to solve this 
> problem?
>  
>   
>  
> Thanks,
>  
>   
>  
> Bob
> 
> 
> 
> 
> 
> 
> 
>  
> ____________________________________________________________________________________
> Looking for earth-friendly autos? 
> Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
> http://autos.yahoo.com/green_center/


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


Mime
View raw message