hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Suladna <sula...@yahoo.com>
Subject Re: java.net.SocketException: Software caused connection abort: recv failed
Date Fri, 26 Sep 2008 19:51:55 GMT
Thanks for the reply Oleg. Is it possible to tell HttpClient to try to reconnect a certain
number of times (e.g. every 5:th second during 1 minute) before the exception is thrown? I
guess the thing that interrupts it is something temporary.


--- On Thu, 9/25/08, Oleg Kalnichevski <olegk@apache.org> wrote:

From: Oleg Kalnichevski <olegk@apache.org>
Subject: Re: java.net.SocketException: Software caused connection abort: recv failed
To: "HttpClient User Discussion" <httpclient-users@hc.apache.org>
Date: Thursday, September 25, 2008, 6:17 PM

On Wed, 2008-09-24 at 02:28 -0700, Suladna wrote:
> Hi!
>  
> I use HttpClient to connect to different websites which are all under
> the same domain. After having connected to a site and brought its
> html-code to my java-program, I wait 5 seconds until I connect to the
> next site (using Thread.sleep).
>  
> I start by making one HttpHost and defining a HttpEntity and
> HttpRespons
>  
> final HttpHost target = new HttpHost("www.xxxxxxx.se", 80,
"http");
> HttpEntity entity = null;
> HttpResponse rsp = null;
>  
> After that I use a loop to connect to each subsite, having the
> adresses urlEnding. I write the following in the loop:
>  
> HttpRequest req = createRequest(urlEnding);
> rsp = client.execute(target, req);
> String[] line =
> EntityUtils.toString(rsp.getEntity()).split("\n");  //this
info is
> used by program 
> 
> if (entity != null){ 
> 
>   entity.consumeContent(); 
> 
> }
>  
> And now to my problem:
>  
> After having connected to a number of websites (the number varies) I
> often get a java.net.SocketException. Please see the attached bmp-file
> for the whole stack. In the case of the attached file, I manage to
> connect to 243 websites before the exception is thrown.
>  
> Interestingly, the java-function that should send me an e-mail after
> the HttpClient is finished with its work then also throws an exception
> (IpClientException). I suppose these problems are connected in some
> way.
>  
> Best regards,
> Sul Adna
> 

Sul Adna,

HTTP connections somethings get terminated abnormally for various
reasons, for instance, due to a firewall dropping the connection or the
target server being under heavy load. 

A well behaved HTTP agent ought to be prepared to deal with I/O
exceptions of that kind.

Hope this helps

Oleg

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org


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




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