You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Prasad Sethumadhavan <PS...@sandcherry.com> on 2005/02/09 00:43:54 UTC

Socket Exception

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.jav
a:1112)
	at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpCon
nectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1379)
	at
org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBa
se.java:1825)
	at
org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase
.java:1588)
	at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java
:999)
	at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMe
thodDirector.java:382)
	at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMetho
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


Re: Socket Exception

Posted by Oleg Kalnichevski <ol...@apache.org>.
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.jav
> a:1112)
> 	at
> org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpCon
> nectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1379)
> 	at
> org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBa
> se.java:1825)
> 	at
> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase
> .java:1588)
> 	at
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java
> :999)
> 	at
> org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMe
> thodDirector.java:382)
> 	at
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMetho
> 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