bliako has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks, I am accessing a server with LWP::UserAgent over SSL for some time now and just recently I encountered this 500 Server closed connection without sending any data back (Client-Warning: Internal response). It appears randomly but often. Some comments I read suggested that this happens at the SSL setup phase where server closes connection and LWP issues this warning (hence Internal response). I have allowed a large timeout of 600s in the setup of LWP::UserAgent.
I have created a simple script to hit an irrelevant server (not the one I use for obvious reasons) just to test whether I have setup LWP+SSL correctly and also getting maximum debugging information.
#!/usr/bin/perl use Test::More; use LWP::ConsoleLogger::Easy qw( debug_ua ); use IO::Socket::SSL; use LWP::UserAgent; my $DEBUG = 1; my $num_tests = 0; my %pages = ( # some name for the page to hit 'google' => [ # the url to hit 'https://www.google.com', # regex obj to validate returned content qr/Google Search/, ], ); my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 1 }); if( $DEBUG == 1 ){ LWP::ConsoleLogger::Easy::debug_ua($ua, 6); $IO::Socket::SSL::DEBUG = 3; } my ($response, $content, $aurl, $regex_validator, $apage); foreach $apage (keys %pages){ ($aurl, $regex_validator) = @{$pages{$apage}}; $response = $ua->get($aurl); ok(defined($response), "$apage hit : $aurl"); $num_tests++; ok($response->is_success==1, "$apage hit got success status co +de : $aurl") or BAIL_OUT("$apage : failed to hit : $aurl"); $num_test +s++; $content = $response->decoded_content; ok($content =~ $regex_validator, "$apage validated OK") or pri +nt "$apage : failed to validate the following content:\n".$content."\ +nend content.\n"; $num_tests++; } # END done_testing($num_tests);
Here is part of the output:
DEBUG: .../IO/Socket/SSL.pm:2853: new ctx 93957261363856 DEBUG: .../IO/Socket/SSL.pm:692: socket not yet connected DEBUG: .../IO/Socket/SSL.pm:694: socket connected DEBUG: .../IO/Socket/SSL.pm:717: ssl handshake not started DEBUG: .../IO/Socket/SSL.pm:750: using SNI with hostname www.google.co +m DEBUG: .../IO/Socket/SSL.pm:785: request OCSP stapling DEBUG: .../IO/Socket/SSL.pm:806: set socket to non-blocking to enforce + timeout=180 DEBUG: .../IO/Socket/SSL.pm:819: call Net::SSLeay::connect DEBUG: .../IO/Socket/SSL.pm:822: done Net::SSLeay::connect -> -1 DEBUG: .../IO/Socket/SSL.pm:832: ssl handshake in progress DEBUG: .../IO/Socket/SSL.pm:842: waiting for fd to become ready: SSL w +ants a read first DEBUG: .../IO/Socket/SSL.pm:862: socket ready, retrying connect DEBUG: .../IO/Socket/SSL.pm:819: call Net::SSLeay::connect DEBUG: .../IO/Socket/SSL.pm:2707: ok=1 [2] /OU=GlobalSign Root CA - R2 +/O=GlobalSign/CN=GlobalSign/OU=GlobalSign Root CA - R2/O=GlobalSign/C +N=GlobalSign
When hitting my server (and not google) the process hangs exactly at waiting for fd to become ready: SSL wants a read first but with a slightly different output (it does not have did not get stapled OCSP response) and repeated instances of:
DEBUG: .../IO/Socket/SSL.pm:832: ssl handshake in progress DEBUG: .../IO/Socket/SSL.pm:842: waiting for fd to become ready: SSL w +ants a read first DEBUG: .../IO/Socket/SSL.pm:862: socket ready, retrying connect DEBUG: .../IO/Socket/SSL.pm:819: call Net::SSLeay::connect DEBUG: .../IO/Socket/SSL.pm:822: done Net::SSLeay::connect -> -1
I am asking for your wisdom. My questions are:
Run on latest Linux kernel with perl v5.26.2, OpenSSL 1.1.0, IO::Socket::SSL 2.060, Net::SSLeay 1.85
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SSLeay::connect -> -1
by haj (Vicar) on Oct 23, 2018 at 20:35 UTC | |
by bliako (Abbot) on Oct 23, 2018 at 22:00 UTC | |
by haj (Vicar) on Oct 23, 2018 at 22:46 UTC | |
by bliako (Abbot) on Oct 24, 2018 at 10:37 UTC | |
by haj (Vicar) on Oct 24, 2018 at 12:38 UTC |