hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joan Balaguero" <joan.balagu...@grupoventus.com>
Subject Sometimes response timeout seems to not work
Date Tue, 23 Mar 2010 13:31:19 GMT
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).

 

This is the dump of one of these threads:

Name: http-80-795

State: RUNNABLE

Total blocked: 3.603  Total waited: 3.127

 

Stack trace: 

java.net.SocketInputStream.socketRead0(Native Method)

java.net.SocketInputStream.read(Unknown Source)

org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessio
nInputBuffer.java:130)

org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:
127)

org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionI
nputBuffer.java:233)

org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponsePar
ser.java:98)

org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.ja
va:210)

org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(Abst
ractHttpClientConnection.java:271)

org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(Defa
ultClientConnection.java:227)

org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(Ab
stractClientConnAdapter.java:229)

org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestEx
ecutor.java:292)

org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.jav
a:126)

org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDir
ector.java:447)

org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.ja
va:641)

org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.ja
va:576)

org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.ja
va:554)

com.vpfw.proxy.services.C.C.A(Unknown Source)

com.vpfw.proxy.services.C.C.A(Unknown Source)

com.vpfw.proxy.services.C.C.A(Unknown Source)

com.vpfw.proxy.servlet.E.A(Unknown Source)

com.vpfw.proxy.servlet.G.service(Unknown Source)

javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:290)

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)

org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:233)

org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
)

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
)

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)

org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)

org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)

org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:583)

org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

java.lang.Thread.run(Unknown Source)

 

 

The pool seems to work well, the connections are obtained and returned to
the pool correctly.

 

Could anybody help me to understand what's going on? If a http dump is
needed, I'll try to do it (it's a production environment with an average of
500 http  simultaneous requests to the webservices).

 

Thanks in advance,

 

Joan.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message