Perl AnyEvent throwing HTTP Error 595 -
i have been trying make asynchronous requests using perl anyevent http module following code.
my $headers = { 'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'accept-language'=> 'en-us,en;q=0.5', 'connection' => 'keep-alive' }; $request = http_request ( => "$url", timeout => 5, # seconds # persistent => 1, # keepalive => 1, headers => $headers, proxy => $proxyref, sub { ($body, $hdr) = @_; } );
i keep getting following response request:
{ 'reason' => 'connection timed out', 'url' => 'url requested', 'status' => 595 };
i've been checking anyevent documentation reasons error, haven't been successful that. cant find other useful threads on issue except suggestions retry on timeout, yields same result. simple 'wget' works on same url , alive. point out on how debug issue?
the "connction timed out" error indicates underlying tcp connect timed out. is, when anyevent::http tries connect web server or proxy, connection request times out (usually after 30 seconds). there no way influence timeout portably.
specifically, problem not problem request (that phase hasn't been entered yet), nor dns resolution, nor server refuses connection. problem server doesn't answer, i.e. switched off, internet connection between , server failed, or firewall silently blocks connection.
update
i got report user ran problem due different problem - started http request , instead of returning event loop, blocked program longer timeout (using sleep
). in other words, started http request , kept event library working. when control rturned, anyevent::http immediatelly timeouted, couldn't create connection in time.
seeing timeout small, reason - anyevent::http cannot know whether connection timeouts because of server/network delay or because couldn't enough cpu time request in required time.
the fix in such case either icnrease timeout conveniently longer there enough time if little cpu time available, or restructure program written in event-based way, running event loop , using timer instead of sleep.
Comments
Post a Comment