There are problems with timeout, apparently, at least with not responding webservers (dns timeout by example) :
I got timeouts of sometimes more than _5_min_ or more instead of 30secs
via $ua->timeout(30)! It's like the timeout setting does not exists.
Tested with LWP 5.69 (perl 5.8.0) and with LWP 5.43 (perl 5.005_03).
I also saw users that got 20min timeouts.
Is this a (very annoying) bug ? What can be done about it ?
Searching archives I found this:
From: Gisle Aas Subject: Re: $ua->timeout info Date: Wed, 06 Feb 2002 10:42:15 -0800 (...) timeout setting (...) 1) It is passed in as Timeout argument to IO::Socket::INET's constructor. IO::Socket::INET currently only use this to fail the connect(2) call if it takes too long. The DNS lookup of the hostname is done by IO::Socket::INET before it even considers the timeout.
Does this mean that, for a DNS timeout, any app using LWP will takes much too long to exit ?
Looking rapidly to the CVS source, I saw that the timeout things seems to be put in comment in IO::Socket::INET and IO::Socket ! What's going on ?
Could someone put me in the right direction ?
Here's a simple code to show the pblm. The 5 secs asked turned out to be 21 secs. And no, I'm not behind a 33k modem ;-) time test.pl: real 0m21.901s user 0m0.110s sys 0m0.000s
------------------------------------ #!/usr/bin/perl -w
use HTTP::Request; use LWP::UserAgent;
$url= 'http://www.busca.net'; # or undefined dns domain $ua= new LWP::UserAgent; $ua->timeout(5); $request= new HTTP::Request('GET', $url); $response= $ua->request($request); # code 500 after a (too long) time print "... Received code " . $response->code . "\n"; ------------------------------------
Thanks in advance.
Christophe