I haven't used HttpClient 3.1 for a while now, so I'm not up on the typical connection management problems.

I don't think that two threads will share the same connection. If the server happens to close a connection in between requests, and the connection is being reused (which is typical) then socket exceptions can and do happen. E.g. if somebody tweaked the server config to reduce the keep-alive time, then you'd start seeing an increased number of these.

You could turn on wire logging, and try to capture a trace of what happens during one of these exceptions.

-- Ken

PS - With HC 4.0, all of my connection management issues were my fault, in the end :)

On Mar 23, 2010, at 3:20pm, Mohit Anchlia wrote:

We are using httpclient in tomcat. We do several requests per sec.
Recently we started to see increasing number of "reset" execptions.
For some reason I am starting to think that it could be because of how
HttpClient is handling "closeIdleConnections". It looks like there
could be a timing issue. For eg: Request A got connect x1 but some
other thread that executed closeIdleConnections got rid of x1. Now
when Request A tried to execute x1 it got reset. Has anyone seen any
such problem before? Only other option would be to grab netstat and
tcpdump as a last resort.

----
java.net.SocketException: Connection reset
       at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.io.BufferedInputStream.fill(BufferedInputStream.java: 218) at java.io.BufferedInputStream.read(BufferedInputStream.java: 235) at org.apache.commons.httpclient.HttpParser.readRawLine(Unknown Source) at org.apache.commons.httpclient.HttpParser.readLine(Unknown Source) at org.apache.commons.httpclient.HttpConnection.readLine(Unknown Source) at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager $HttpConnectionAdapter.readLine(Unknown
Source)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(Unknown
Source)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(Unknown
Source)
at org.apache.commons.httpclient.HttpMethodBase.execute(Unknown Source) at org .apache.commons.httpclient.HttpMethodDirector.executeWithRetry(Unknown
Source)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(Unknown
Source)
at org.apache.commons.httpclient.HttpClient.executeMethod(Unknown
Source)
at org.apache.commons.httpclient.HttpClient.executeMethod(Unknown
Source)
---

On server side we don't see such a request coming in.

Which I think is expected, if the server has closed the connection and that's why you're getting this exception.

Server side seem
to have enough capacity

I'd check the keep-alive settings for the server.

and these errors have occurred even during non
busy hours. I am suspecting something to do with how keep alive is
being handled.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


--------------------------------------------
Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c   w e b   m i n i n g





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to