Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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 milu (Initiate)
on Feb 28, 2012 at 00:12 UTC ( [id://956556]=perlquestion: print w/replies, xml ) Need Help??

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

I posted the full details over at StackOverflow.com, but the available wisdom wasn't sufficient to answer the question, so I'm reposting it here. Or rather, I'm pointing to the original question, sort of advertising it, so here goes:

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!

Update

So here's a copy and paste of my question on StackOverflow.com:


Relevance: It is annoying to see your HTTPS client block indefinitely because the connection endpoint is unreliable.

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`:

nc -k -l localhost 9999 # on Linux, for multiple requests nc -l -p 9999 localhost # on Cygwin, for one request only
Then, point the script to this tarpit:
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; }
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).

Versions used:

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
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 :)

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.

  • Comment on What part of the software stack might cause the timeout on LWP::UserAgent via HTTPS to fail with some perls on Linux and Windows?
  • Select or Download Code

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
    I'm also experiencing this. Connections will sometimes hang for days, and my users will complain that orders (which is what the application does) are not being processed. Quite frustrating. I am now putting an alarm timeout over the connection code.
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
      Thank you, anonymous poster, this is precisely what I wanted to know.
        Ah, sorry, I posted too quickly. Timeout does work on Windows, just not via SSL. So I'm not sure the info back from 2004 about non-blocking not supported on Windows still applies. I have seen it to work on Windows, just not via SSL.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-24 22:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found