hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@redwerk.com
Subject Re: socket errors (connection reset, read timed out)
Date Thu, 09 Nov 2006 18:18:05 GMT
On Thu, Nov 09, 2006 at 06:32:23PM +0100, Oleg Kalnichevski wrote:
> Eugeny,
> 
> The fact that it sort of always works with Firefox (or any other browser
> for that matter) does not mean much to me, because we do not know how
> many times Firefox retries the request before it succeeds in retrieving
> the content of the URL.

Okay, is it possible to tell HttpClient try, for instance, 5 times before
giving up with such Exception?

> > Stack traces:
> > 
> > 10/Nov/2006 00:14:38 ERROR [pool-1-thread-1] - java.net.ConnectException: Connection
timed out
> > java.net.ConnectException: Connection timed out
> >         at java.net.PlainSocketImpl.socketConnect(Native Method)
> >         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
> >         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
> >         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
> >         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
> >         at java.net.Socket.connect(Socket.java:516)
> >         at java.net.Socket.connect(Socket.java:466)
> >         at java.net.Socket.<init>(Socket.java:366)
> >         at java.net.Socket.<init>(Socket.java:239)
> >         at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.
> > java:79)
> >         at org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$1.doit(ControllerThreadSocketFactory.java
> > :90)
> >         at org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$SocketTask.run(ControllerThreadSocketFact
> > ory.java:157)
> >         at java.lang.Thread.run(Thread.java:595)
> What kind of JRE is your application running on? I suspect you are still
> using a 1.3 JVM. Is that correct?


java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)

> > 09/Nov/2006 17:28:44 ERROR [pool-1-thread-8] - java.net.SocketException: Connection
reset
> > java.net.SocketException: Connection reset
> >         at java.net.SocketInputStream.read(SocketInputStream.java:168)
> >         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:77)
> >         at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105)
> >         at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1115)
> >         at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedH
> > ttpConnectionManager.java:1373)
> >         at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1832)
> 
> -------------------------------^
> 
> This exception is perfectly legitimate. The server dropped the
> connection before sending out a valid HTTP response, most likely due to
> being under heavy load / running low on resources. This is not nice but
> can be expected in the real life. Your code should implement a
> recovery / retry mechanism to compensate for such failures

My application tries several times to access URLs, if face some issues, and
all times same exception is thrown. If I access the server, which drops the
connection, with firefox - when my application downloads data from it - I
don't face any of such exception - page loads without any problem.

---------------------------------------------------------------------
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