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 Oleg Kalnichevski <ol...@apache.org> on 2008/09/25 20:17:40 UTC
Re: java.net.SocketException: Software caused connection abort:
recv failed
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
Re: java.net.SocketException: Software caused connection abort: recv failed
Posted by Suladna <su...@yahoo.com>.
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 <ol...@apache.org> wrote:
From: Oleg Kalnichevski <ol...@apache.org>
Subject: Re: java.net.SocketException: Software caused connection abort: recv failed
To: "HttpClient User Discussion" <ht...@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