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.


In reply to 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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.