hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: recovery of ther HTTPClient after connection disruption - retrying of the HttpRequest
Date Wed, 30 Jan 2013 13:28:00 GMT
On Wed, 2013-01-30 at 13:43 +0100, Bronislav Gabrhelik wrote:
> The original problem I am trying to solve is connection disruption after
> resume from the sleep mode (on Windows). When the machine is resumed the
> TCP/IP stack is not ready yet, so all requests queued and processed at the
> time of rebuilding TCP/IP connectivity are failed. Note that the time
> needed for complete recovery in Java is even longer because of DNS caching.
> Especially negative TTL has negative impact as it is explicitly set to 10
> seconds in java.security, so there is no chance to change it in run-time or
> by the system property.
> 
> I simulate sleep/resume with disconnecting and connecting of the NIC of the
> virtual machine, so I am able to debug problem.
> 
> When HttpClient.execute throws some specific exceptions (like
> SocketException) we detect that if there are some changes on NIC adapter
> configuration and wait for TCP/IP stack recovery (the special JNI was
> needed). When conditions are stable we retry to execute  the same
> HttpRequest. Note that the HttpRequest is reset by reset() method before
> retry.
> 
> Unfortunately the execution hangs in AbstractHttpClientConnection.isStale()
> for some time like 30 secs (see the stack below). After this problem  I
> tried to close the connection with  HttpRequest.abort() to avoid hang, but
> I have had no success. Finally the request is failed with
> NoHttpResponseException.
> 
> How can I recover the HttpClient and/or HttpRequest so I can retry it.
> 
> Note that we use some older version of HttpClient - 4.2-alpha +
> HttpComponents - 4.1
> 

The HttpRequest#abort() interrupts request execution by shutting down
the underlying socket. If socket shutdown does not unblock I/O
operations blocked on it, I would suspect a JRE level issue. Try
upgrading your JRE and see if that makes a difference.

Having said that, since you are using JNI anyway, why not simply
shutting HttpClient down upon a pre-suspend notification?  

Oleg



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


Mime
View raw message