milu has asked for the wisdom of the Perl Monks concerning the following question:
Make timeout work for LWP::UserAgent HTTPS
http://stackoverflow.com/q/9400068/269126
Bottom line is: ActivePerl on Windows and Liux as well as Cygwin perl (on Windows, of course) appear to have problems.
How would I go about even starting to find an issue such as this, which might be in Perl or any of the used libraries? (And probably not in the Perl code used in LWP and so on.)
Thanks!
So here's a copy and paste of my question on StackOverflow.com:
This experiment is easy to set up and replay at home. You just need two things, a tarpit to trap an incoming client, and a Perl script. The tarpit can be set up using `netcat`:
Then, point the script to this tarpit:nc -k -l localhost 9999 # on Linux, for multiple requests nc -l -p 9999 localhost # on Cygwin, for one request only
What is this going to do? Well, connect to the port opened by NetCat, and then ... hang. Indefinitely. At least in terms of developer time. I mean it might time out after ten minutes or two hours, but I haven't checked; the specified timeout doesn't take effect, not on Linux, and not on Windows (Win32, haven't checked Cygwin).use strict; use LWP::UserAgent; use HTTP::Request::Common; print 'LWP::UserAgent::VERSION ', $LWP::UserAgent::VERSION, "\n"; print 'IO::Socket::SSL::VERSION ', $IO::Socket::SSL::VERSION, "\n" +; my $ua = LWP::UserAgent->new( timeout => 5, keep_alive => 1 ); $ua->ssl_opts( timeout => 5, Timeout => 5 ); # Yes - see note belo +w! my $rsp = $ua->request( GET 'https://localhost:9999' ); if ( $rsp->is_success ) { print $rsp->as_string; } else { die $rsp->status_line; }
Versions used:
Now for the `timeout` and `Timeout` parameters. The former is the name of the parameter for LWP::UA(https://metacpan.org/module/LWP::UserAgent), the latter is the name for IO::Socket::SSL(https://metacpan.org/module/IO::Socket::SSL), used via LWP::Protocol::https(https://metacpan.org/module/LWP::Protocol::https). (Incidentally, why is metacpan HTTPS? Well, at least it's not a tarpit.) I am somehow hoping to have these parameters passed along :)LWP::UserAgent::VERSION 6.02 IO::Socket::SSL::VERSION 1.44 # on Linux LWP::UserAgent::VERSION 6.02 IO::Socket::SSL::VERSION 1.44 # on Win32
Just so you know, `keep_alive` doesn't have anything to do with the timeout not working, I verified that empirically. :)
Anyway, before digging deeper, does anyone know what's going on here and how to make the timeout work with HTTPS? Hard to believe I'm the first person running into this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What part of the software stack might cause the timeout on LWP::UserAgent via HTTPS to fail with some perls on Linux and Windows?
by Anonymous Monk on Feb 28, 2012 at 02:14 UTC | |
|
Re: What part of the software stack might cause the timeout on LWP::UserAgent via HTTPS to fail with some perls on Linux and Windows?
by Anonymous Monk on Mar 16, 2012 at 00:33 UTC | |
|
Re: What part of the software stack might cause the timeout on LWP::UserAgent via HTTPS to fail with some perls on Linux and Windows?
by Anonymous Monk on Mar 16, 2012 at 04:10 UTC | |
by milu (Initiate) on Mar 26, 2012 at 08:46 UTC | |
by milu (Initiate) on Mar 26, 2012 at 09:03 UTC |