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: Sometimes response timeout seems to not work
Date Tue, 23 Mar 2010 13:36:39 GMT
On Tue, 2010-03-23 at 14:31 +0100, Joan Balaguero wrote:
> Hello,
> 
>  
> 
> We're querying  a webservice using a 'ThreadSafeClientConnManager'. 
> 
> Platform: windows 2003 Server 64bit
> 
> httpClient 4.0
> 
> jre 6 update 13 on Tomcat 6.0.18
> 
>  
> 
> We're setting a global response timeout with:
> 
> HttpParams objHttpParams = new BasicHttpParams();
> 
> HttpProtocolParams.setVersion(objHttpParams, HttpVersion.HTTP_1_1);
> 
> HttpConnectionParams.setSoTimeout(objHttpParams, responseTimeout);
> 
> ClientConnectionManager cm = new ThreadSafeClientConnManager(objHttpParams,
> HttpUtils.createDefaultSchemeRegistry());
> 
> this.objHttp                = new DefaultHttpClient(cm, objHttpParams);
> 
>  
> 
> For every webservice call, if the response timeout (at call level) is
> greater than 0 then:
> 
> if (objCall.responseTimeout != 0)
> objPost.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,
> objCall.responseTimeout); 
> 
>  
> 
> Then we send the request:
> 
> StringEntity entity = new StringEntity(request.createRequestParameters());
> 
> entity.setContentType(request.contentType);
> 
> objPost.setEntity(entity);
> 
>           
> 
> return (this.objHttp.execute(objPost));
> 
>  
> 
> And we read the response:
> 
> bis                          = new BufferedInputStream(entity.getContent());
> 
> ByteArrayOutputStream buffer = new ByteArrayOutputStream(httpOutBufferSize);
> 
> byte[] tmp                   = new byte[httpOutBufferSize];
> 
> int numBytesRead             = 0;
> 
>  
> 
> while ((numBytesRead = bis.read(tmp)) >= 0) buffer.write(tmp, 0,
> numBytesRead);
> 
> bis.close();
> 
> bis = null;
> 
>  
> 
> 
> 
> Performing a thread dump, we can see many threads blocked waiting a response
> several minutes (2,3,4 minutes) when the maximum response timeout is 60
> seconds (at webservice and call level).
> 

Please see definition of the socket timeout

Oleg



---------------------------------------------------------------------
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