hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <ossf...@dubioso.net>
Subject Re: Detecting lost network connection?!
Date Mon, 20 Aug 2007 08:08:29 GMT
Hi Michael,

> I'm receiving a file via HTTP-GET and then simply
> disconnect the computer from the internet. My program stops receiving
> anything but does not throw a SocketTimeoutException or something
> similar although I've set all (?) the necessary parameters on the
> HttpClient and GetMethod (please see sample code below!).

The actual read operation on the socket calls somewhere into
native code. If the TCP/IP subsystem of your machine and/or
of the JVM you are using does not detect the lost connection
and trigger an error, then HttpClient can do nothing about it.
Have you checked whether other users of the Mac JDK have
reported similar problems, not necessarily with HttpClient?

> I thought that something like
> client.getHttpConnectionManager().closeIdleConnections(10000); would do
> the job but it doesn't.

A connection that is allocated by your application is not idle.
Idle connections are those that have been returned by applications.

A workaround would be to start a second thread that monitors
the application and calls method.abort() if the download stalls.
Check the stack trace of the exception that is triggered to see
where exactly the thread was blocked.

>         client.getHttpConnectionManager().getParams().setSoTimeout(5000);
>         client.getParams().setSoTimeout(5000);
>         get.getParams().setSoTimeout(5000);

Doesn't look like you missed one.

cheers,
  Roland


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