hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen J. Butler" <stephen.but...@gmail.com>
Subject Re: Right way to timeout
Date Mon, 17 Dec 2012 19:31:21 GMT
On Mon, Dec 17, 2012 at 7:29 AM, Jean-Marc Spaggiari <
jean-marc@spaggiari.org> wrote:

> I was doing that the oposite way. I mean, I was starting the request
> on a thread, checkinv every 100ms if it was done, and killing it after
> a certain period of time. But some time the abort was not working and
> it was feeling my memory with pending threads...
>

If you're worried about filling your app with abort checking threads then
you could adapt my solution to use only a single thread that runs for the
entire app lifetime. Just (in a multithreaded way) add each request to a
queue sorted by the absolute timeout time. Then your abort thread wakes up
every second and shifts items off the bottom of the queue that should be
aborted.


> If I use such a solution, does it mean that the 2 TimeOut that I'm
> already setting are useless? Will the abort close both the TCP and the
> HTTP connections?
>

I wouldn't say they're useless, but I would suggest setting the thresholds
lower. For example, if the server takes 20 seconds to finish the TCP
connection handshake, will it really perform your request in the remaining
10? Unlikely.

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