hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "hakan.jacobsson" <hakan.jacobs...@aftonbladet.se>
Subject Timeout settings not working properly
Date Mon, 19 Jan 2009 10:39:46 GMT
Hi,

I'm using HttpClient 3.1 to connect to a server.
I've set both the connection timeout and the socket timeout.
I set the connection timeout in the HttpConnectionManager (later set  
in HttpClient) like this:

------------

			MultiThreadedHttpConnectionManager cm = new  
MultiThreadedHttpConnectionManager();
			//connection timeout - same value as for socket timeout (set in  
the PostMethod - see below))
			cm.getParams().setConnectionTimeout(Integer.parseInt(getProperty 
(MADS_AD_TIMEOUT)));
			//set HttpConnectionManager in HttpClient
			madsClient.setHttpConnectionManager(cm);

------------

I set the sockettimeout in the PostMethod class like this:

------------
			//retry and socket timeout settings (result = an instance of  
PostMethod)
			result.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,  
new DefaultHttpMethodRetryHandler(1, false));
			//socket timeout (connection timeout already set in HttpClient)
			result.getParams().setSoTimeout(Integer.parseInt(getProperty 
(MADS_AD_TIMEOUT)));

-------------

At times (when the server we connect to is slow on response?) the  
requests still wait for a much longer time than the timeout we use  
(500 ms).
A SocketTimeout/ConnectionTimeout-exception is thrown, but this might  
take a very long time (48 seconds is a recent example). We measure  
the time in
our code.

Any idea what might cause this problem?

/best regards, HÃ¥kan Jacobsson, System developer in Stockholm, Sweden.
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message