Timeout with persistent connections

Marc Lehmann schmorp at schmorp.de
Mon Jul 25 18:19:31 CEST 2011


On Mon, Jul 25, 2011 at 05:32:33PM +0200, Martin Parm <mp at leasingborsen.dk> wrote:
> 	sleep 6;

This is the problem. Basically, you stop the time for an extended period
without telling the event loop (which still thinks it is 6 seconds past
when new timeouts are created). Since 6 seconds is long enough for a
timeout to occur, one does occur immediately.

The solution would be to call AnyEvent->now_update after the sleep, so the
event loop can catch up with the missed time.

Think about it that way: if you would have the sleep between sending the
request and processing the results, it would also timeout.

> Shouldn't AnyEvent::HTTP automatically reconnect on timeouts?

No, that would be just the wrong thing to do - if we get a timeout,
it could mean any number of things, for example that the server is
overloaded, in which case retrying makes things worse. There is no real
expectation that reconnecting after a timeout will result in anything
better.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list