hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Bowen <s...@yahoo.com>
Subject Connection tmeout for objPost / objGet?
Date Fri, 30 Mar 2007 12:09:46 GMT

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:
 
  
 
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/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message