Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

True timeout (nonblocking) on LWP::UserAgent request method?

by tomfahle (Priest)
on Sep 25, 2008 at 22:49 UTC ( #713763=perlquestion: print w/replies, xml ) Need Help??

tomfahle has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

I am trying to implement a HTTP-Request (GET) to an unreliable server. The problem is that the server will occasionally deadlock and the request will never succeed. That is the programm runs forever.

Update

To clarify the problem: connect is succesfull (200 OK). But while retrieving the content of the response, the server stucks. Then the connection hangs forever.

I just want to skip the blocking page, that is terminate that request on my side, and do the next request or stop the programm.

DNS is working fine.

Setting a timeout ( $ua->timeout() ) or an alarm doesn't work.

I am aware of Get Timout with LWP which adresses the same problem.

There's a similar thread at StackOverFlow: True timeout on LWP::UserAgent request method which suggests using SigAction.

Is there a convenient way to put LWP::UserAgent or WWW::Mechanize in nonblocking mode (like IO::Socket::INET )?

Update

As of perrin's reply:

I've tested it on a W2003 Server with Activstate Perl 5.8.8 and 5.10.0.1004 and on Linux 2.6.24-19-generic with Perl 5.8.8 and 5.10.

Thomas

  • Comment on True timeout (nonblocking) on LWP::UserAgent request method?

Replies are listed 'Best First'.
Re: True timeout (nonblocking) on LWP::UserAgent request method?
by perrin (Chancellor) on Sep 25, 2008 at 23:14 UTC
    The old LWP FAQ has answers to this. I'm guessing you're on Win32 if alarm() doesn't work for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://713763]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2021-10-26 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (90 votes). Check out past polls.

    Notices?