Subject: | Timeout problem on linux |
This is perl, v5.8.8 built for i386-linux-thread-multi
Linux 2.6.18-128.1.16.el5 #1 SMP Tue Jun 30 06:10:28 EDT 2009 i686 i686 i386 GNU/Linux
Problem:
On linux I get a very long timeout doing a request to a https page that is not responding.
On windows it fails after 22 seconds.
On linux it fails after 189 seconds.
On windows:
--------------------------------------------------------------------------------------
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
my $starttime = time;
my $response = $ua->get('https://www.laptopshop.co.uk/miscpages/sitealarmcheck.htm');
if ($response->is_success) {
print "request sucess\n";
}else {
print $response->status_line . "\n";
}
my $endtime = time;
print "time used: ".($endtime - $starttime)." seconds\n";
^D500 Connect failed: connect: Unknown error; Unknown error
time used: 22 seconds
--------------------------------------------------------------------------------------
On linux (CentOS release 5.3 (Final)):
--------------------------------------------------------------------------------------
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
my $starttime = time;
my $response = $ua->get('https://www.laptopshop.co.uk/miscpages/sitealarmcheck.htm');
if ($response->is_success) {
print "request sucess\n";
}else {
print $response->status_line . "\n";
}
my $endtime = time;
print "time used: ".($endtime - $starttime)." seconds\n";
500 Connect failed: connect: Connection timed out; Connection timed out
time used: 189 seconds
--------------------------------------------------------------------------------------
I tried to debug perl via the -d switch and I can se that it hangs on line
IO::Socket::connect(/usr/lib/perl5/5.8.8/i386-linux-thread-multi/IO/Socket.pm:114):
114: if (!connect($sock, $addr)) {
This is the stack trace some steps after the above line:
$ = Carp::short_error_loc() called from file `/usr/lib/perl5/5.8.8/Carp/Heavy.pm' line 187
@ = Carp::shortmess_heavy('') called from file `/usr/lib/perl5/5.8.8/Carp.pm' line 260
@ = Carp::shortmess('') called from file `/usr/lib/perl5/5.8.8/Carp.pm' line 269
. = Carp::croak('') called from file `/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Net/SSL.pm' line 113
$ = Net::SSL::connect(ref(LWP::Protocol::https::Socket), '^B^@^AM-;^M-eM-!M-W^@^@^@^@^@^@^@^@') called from file `/usr/lib/perl5/5.8.8/IO/Socket/INET.pm' line 199
$ = IO::Socket::INET::configure(ref(LWP::Protocol::https::Socket), ref(HASH)) called from file `/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Net/SSL.pm' line 71
$ = Net::SSL::configure(ref(LWP::Protocol::https::Socket), ref(HASH)) called from file `/usr/lib/perl5/site_perl/5.8.8/Net/HTTPS.pm' line 47
$ = Net::HTTPS::http_connect(ref(LWP::Protocol::https::Socket), ref(HASH)) called from file `/usr/lib/perl5/site_perl/5.8.8/Net/HTTP/Methods.pm' line 76
$ = Net::HTTP::Methods::http_configure(ref(LWP::Protocol::https::Socket), ref(HASH)) called from file `/usr/lib/perl5/site_perl/5.8.8/Net/HTTPS.pm' line 42
$ = Net::HTTPS::configure(ref(LWP::Protocol::https::Socket), ref(HASH)) called from file `/usr/lib/perl5/5.8.8/i386-linux-thread-multi/IO/Socket.pm' line 48
$ = IO::Socket::new('LWP::Protocol::https::Socket', 'Proto', 'tcp', 'PeerAddr', 'www.laptopshop.co.uk', 'SendTE', 1, 'PeerPort', 443, 'Timeout', 10, 'KeepAlive', '') called from file
`/usr/lib/perl5/5.8.8/IO/Socket/INET.pm' line 32
$ = IO::Socket::INET::new('LWP::Protocol::https::Socket', 'Proto', 'tcp', 'PeerAddr', 'www.laptopshop.co.uk', 'SendTE', 1, 'PeerPort', 443, 'Timeout', 10, 'KeepAlive', '') called from file
`/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Net/SSL.pm' line 34
$ = Net::SSL::new('LWP::Protocol::https::Socket', 'PeerAddr', 'www.laptopshop.co.uk', 'PeerPort', 443, 'Proto', 'tcp', 'Timeout', 10, 'KeepAlive', '', 'SendTE', 1) called from file
`/usr/lib/perl5/site_perl/5.8.8/LWP/Protocol/http.pm' line 31
$ = LWP::Protocol::http::_new_socket(ref(LWP::Protocol::https), 'www.laptopshop.co.uk', 443, 10) called from file `/usr/lib/perl5/site_perl/5.8.8/LWP/Protocol/http.pm' line 149
$ = LWP::Protocol::http::request(ref(LWP::Protocol::https), ref(HTTP::Request), undef, undef, undef, 10) called from file `/usr/lib/perl5/site_perl/5.8.8/LWP/UserAgent.pm' line 173
. = eval {...} called from file `/usr/lib/perl5/site_perl/5.8.8/LWP/UserAgent.pm' line 172
$ = LWP::UserAgent::send_request(ref(LWP::UserAgent), ref(HTTP::Request), undef, undef) called from file `/usr/lib/perl5/site_perl/5.8.8/LWP/UserAgent.pm' line 255
$ = LWP::UserAgent::simple_request(ref(LWP::UserAgent), ref(HTTP::Request), undef, undef) called from file `/usr/lib/perl5/site_perl/5.8.8/LWP/UserAgent.pm' line 263
$ = LWP::UserAgent::request(ref(LWP::UserAgent), ref(HTTP::Request)) called from file `/usr/lib/perl5/site_perl/5.8.8/LWP/UserAgent.pm' line 391
$ = LWP::UserAgent::get(ref(LWP::UserAgent), 'https://www.laptopshop.co.uk/miscpages/sitealarmcheck.htm') called from file `test_https.pl' line 7
It can be a problem to reproduce the bug if the webpage:
https://www.laptopshop.co.uk/miscpages/sitealarmcheck.htm
starts to respond again.