hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Prasad Sethumadhavan" <PSethumadha...@sandcherry.com>
Subject RE: Socket Exception
Date Wed, 09 Feb 2005 22:29:17 GMT
Hi Oleg,
Thanks for the reply. I have added a custom retry handler now. However
my main concern is why this exception is happening in the first place.
If I use the http client without any major break (even heavy load tests
with 100-200 clients works great). However if I use the HttpClient
sparsely like once every 3 minutes or so why am I getting this
exception. Is this happening because the http client is resuing
connections and the connection was closed by the server? If so then why
am I getting a "recv failed" consistently? 
I guess this use case of using the http client sparsely is very common.
So is it a configuration problem on my part? Please help me out.

Thanks
Prasad

-----Original Message-----
From: Oleg Kalnichevski [mailto:olegk@apache.org] 
Sent: Wednesday, February 09, 2005 2:25 PM
To: HttpClient User Discussion
Subject: Re: Socket Exception

Prasad,

See <http://jakarta.apache.org/commons/httpclient/3.0/exception-
handling.html#HTTP%20transport%20safety>

Oleg

On Tue, 2005-02-08 at 16:43 -0700, Prasad Sethumadhavan wrote:
> Hi,
> I am getting a SocketException if I use a HttpClient instance after a 
> gap of 3 minutes.
> 
> //Initialization
> 
>         MultiThreadedHttpConnectionManager manager = 
>             new MultiThreadedHttpConnectionManager();
>         manager.getParams().setStaleCheckingEnabled(true);
>         manager.getParams().setDefaultMaxConnectionsPerHost(
>                 config.getMaxHttpConnections());
>         manager.getParams().setMaxTotalConnections(
>                 config.getMaxHttpConnections());
>         manager.getParams().setConnectionTimeout(
>                 config.getDefaultConnectionTimeout());
>         
>         Httpclient httpclient = new HttpClient(manager);
>         httpclient.getParams().setCookiePolicy(
>                 CookiePolicy.BROWSER_COMPATIBILITY);
> 
> I create a new method to a URL and execute it using 
> httpClient.executeMethod(). I then sleep for 180 seconds and then 
> access the same URL using a newly created method and I am getting the 
> following exception. I can reproduce this consistently.
> 
> Please let me know if there is some property that I need to set to 
> avoid this problem. Also, in my application, requests can come at any 
> time and hence I should be able to use the httpclient after any
interval.
> 
> Thanks in advance
> Prasad
> 
> //Stack Trace
> 
> java.net.SocketException: Software caused connection abort: recv
failed
> 	at java.net.SocketInputStream.socketRead0(Native Method)
> 	at java.net.SocketInputStream.read(SocketInputStream.java:129)
> 	at
> java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
> 	at
> java.io.BufferedInputStream.read(BufferedInputStream.java:235)
> 	at
>
org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:76)
> 	at
> org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:104)
> 	at
> org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.j
> av
> a:1112)
> 	at
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpC
> on
> nectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1379)
> 	at
> org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethod
> Ba
> se.java:1825)
> 	at
> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBa
> se
> .java:1588)
> 	at
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.ja
> va
> :999)
> 	at
> org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(Http
> Me
> thodDirector.java:382)
> 	at
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMet
> ho
> dDirector.java:168)
> 	at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java
> :3
> 93)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> httpclient-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message