Reputation: 305
I am using httpclient 4.1.2. If I do a connect to a particular host XYZ and keep the client program running for more than 5 to 6 hr, connects to the same host XYZ starts giving:
org.apache.http.conn.ConnectTimeoutException: Connect to XYZ timed out
at
org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:377)
at
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
at
org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at
org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at
org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
If I connect to a different host, it will succeed. The problem goes away once I restart my client program. Connecting to the same host through browser will succeed.
Server is a tomcat 6. Both client and server are running on JRE 5. I have set connection timeout = 20000 and socket timeout = 60000. I am using DefaultHttpClient with SingleClientConnManager.
Upvotes: 0
Views: 1928
Reputation: 86
I've seen similar connectivity problems in these cases:
When the programmer does not completely empty the http response object after every request. In particular when you receive an unexpected response code (e.g. 500) - you must still empty the response object.
When there is a firewall/loadbalancer between the client and the server and the request is not being passed to the server. You could look at the number headers you are passing and make sure this is not too high and discard those that are unnecessary.
NOTE: I would consider these timeout values to be extremely high. In general you would expect the server to respond in a couple of seconds rather than tens of seconds.
The wire level logging can be useful in debugging such issues.
Upvotes: 1