Subject: | keep_alive + https == hangs until timeout |
use LWP::UserAgent;
my($keep_alive, $url) = @ARGV;
print LWP::UserAgent->new( keep_alive => $keep_alive, timeout => 10 )->get($url)->content
__END__
0 http://www.google.com works fine
4 http://www.google.com works fine
0 https://www.google.com works fine
4 https://www.google.com times out but returns content
As demonstrated by the program above, and the various combinations of keep_alive and http vs https urls, when keep_alive is set LWP will hang retrieving an https URL until the timeout. Then it will successfully return the content.
Its stuck on this line:
Net::HTTP::Methods::can_read(/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/Net/HTTP/Methods.pm:297):
297: my $nfound = select($fbits, undef, undef, $timeout);
Here's the stack trace.
$ = Net::HTTP::Methods::can_read(ref(LWP::Protocol::https::Socket)) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/Net/HTTP/Methods.pm' line 257
$ = Net::HTTP::Methods::my_readline(ref(LWP::Protocol::https::Socket), 'Entity body') called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/Net/HTTP/Methods.pm' line 507
$ = Net::HTTP::Methods::read_entity_body(ref(LWP::Protocol::https::Socket), '', 4096) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/Protocol/http.pm' line 409
$ = LWP::Protocol::http::__ANON__[/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/Protocol/http.pm:420] called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/Protocol.pm' line 158
. = eval {...} called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/Protocol.pm' line 99
$ = LWP::Protocol::collect(ref(LWP::Protocol::https), undef, ref(HTTP::Response), ref(CODE)) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/Protocol/http.pm' line 420
$ = LWP::Protocol::http::request(ref(LWP::Protocol::https), ref(HTTP::Request), undef, undef, undef, 60) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/UserAgent.pm' line 192
. = eval {...} called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/UserAgent.pm' line 191
$ = LWP::UserAgent::send_request(ref(LWP::UserAgent), ref(HTTP::Request), undef, undef) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/UserAgent.pm' line 274
$ = LWP::UserAgent::simple_request(ref(LWP::UserAgent), ref(HTTP::Request), undef, undef) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/UserAgent.pm' line 282
$ = LWP::UserAgent::request(ref(LWP::UserAgent), ref(HTTP::Request)) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/UserAgent.pm' line 410
$ = LWP::UserAgent::get(ref(LWP::UserAgent), 'https://www.google.com') called from -e line 1
perl 5.16.2 on OS X 10.8.2
LWP 6.04
LWP::Protocol::https 6.03
IO::Socket::SSL 1.81
Net::HTTPS 6.04
my($keep_alive, $url) = @ARGV;
print LWP::UserAgent->new( keep_alive => $keep_alive, timeout => 10 )->get($url)->content
__END__
0 http://www.google.com works fine
4 http://www.google.com works fine
0 https://www.google.com works fine
4 https://www.google.com times out but returns content
As demonstrated by the program above, and the various combinations of keep_alive and http vs https urls, when keep_alive is set LWP will hang retrieving an https URL until the timeout. Then it will successfully return the content.
Its stuck on this line:
Net::HTTP::Methods::can_read(/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/Net/HTTP/Methods.pm:297):
297: my $nfound = select($fbits, undef, undef, $timeout);
Here's the stack trace.
$ = Net::HTTP::Methods::can_read(ref(LWP::Protocol::https::Socket)) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/Net/HTTP/Methods.pm' line 257
$ = Net::HTTP::Methods::my_readline(ref(LWP::Protocol::https::Socket), 'Entity body') called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/Net/HTTP/Methods.pm' line 507
$ = Net::HTTP::Methods::read_entity_body(ref(LWP::Protocol::https::Socket), '', 4096) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/Protocol/http.pm' line 409
$ = LWP::Protocol::http::__ANON__[/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/Protocol/http.pm:420] called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/Protocol.pm' line 158
. = eval {...} called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/Protocol.pm' line 99
$ = LWP::Protocol::collect(ref(LWP::Protocol::https), undef, ref(HTTP::Response), ref(CODE)) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/Protocol/http.pm' line 420
$ = LWP::Protocol::http::request(ref(LWP::Protocol::https), ref(HTTP::Request), undef, undef, undef, 60) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/UserAgent.pm' line 192
. = eval {...} called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/UserAgent.pm' line 191
$ = LWP::UserAgent::send_request(ref(LWP::UserAgent), ref(HTTP::Request), undef, undef) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/UserAgent.pm' line 274
$ = LWP::UserAgent::simple_request(ref(LWP::UserAgent), ref(HTTP::Request), undef, undef) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/UserAgent.pm' line 282
$ = LWP::UserAgent::request(ref(LWP::UserAgent), ref(HTTP::Request)) called from file '/Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/LWP/UserAgent.pm' line 410
$ = LWP::UserAgent::get(ref(LWP::UserAgent), 'https://www.google.com') called from -e line 1
perl 5.16.2 on OS X 10.8.2
LWP 6.04
LWP::Protocol::https 6.03
IO::Socket::SSL 1.81
Net::HTTPS 6.04