Skip Menu |

This queue is for tickets about the Net-Async-HTTP CPAN distribution.

Report information
The Basics
Id: 79402
Status: resolved
Priority: 0/
Queue: Net-Async-HTTP

People
Owner: Nobody in particular
Requestors: stephenclouse [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.17
Fixed in: 0.34



Subject: Script ignores timeout, dies when trying to talk to a firewalled/blackholed port
#!/usr/bin/env perl use IO::Async::Loop (); use Net::Async::HTTP (); use URI (); my @roots = map {URI->new($_)} qw( http://10.1.2.3/ ); my $loop = IO::Async::Loop->new(); my $http = Net::Async::HTTP->new( timeout => 5, ); $loop->add($http); my @res; foreach my $root (@roots) { my $uri = $root->clone; $uri->path('/foo/bar'); $http->do_request( uri => $uri, on_response => sub { my($response) = @_; push @res, $response; $loop->loop_stop if scalar @res >= scalar @roots; }, on_error => sub { warn $_[0]; push @res, HTTP::Response->new( 599, 'Internal Exception', [ Content_Type => 'text/plain', Content_Length => length $_[0], ], $_[0], ); $loop->loop_stop if scalar @res >= scalar @roots; }, ); } $loop->run; print scalar(@res), "\n"; __END__ In this example, 10.1.2.3 is behind a firewall that blocks port 80. Bug #1: The specified 5-second timeout is ignored, script hangs for 30-60 seconds. Bug #2: When the script finally does timeout, it dies instead: Cannot remove child from a parent that doesn't contain it at /opt/perl/lib/vendor_perl/IO/Async/Connector.pm line 395 at /opt/perl/lib/vendor_perl/IO/Async/Notifier.pm line 384 IO::Async::Notifier::remove_child('Net::Async::HTTP=HASH(0xbf77c0)', 'Net::Async::HTTP::Timer=HASH(0x17dd678)') called at /opt/perl/lib/vendor_perl/Net/Async/HTTP.pm line 403 Net::Async::HTTP::__ANON__[/opt/perl/lib/vendor_perl/Net/Async/HTTP.pm:405](undef, '10.9.1.28:80 not contactable [Connection timed out]') called at /opt/perl/lib/vendor_perl/Net/Async/HTTP.pm line 218 Net::Async::HTTP::__ANON__[/opt/perl/lib/vendor_perl/Net/Async/HTTP.pm:219]('connect', 'Connection timed out') called at /opt/perl/lib/vendor_perl/IO/Async/Connector.pm line 395 IO::Async::Connector::__ANON__[/opt/perl/lib/vendor_perl/IO/Async/Connector.pm:396]('connect: Connection timed out at /opt/perl/lib/vendor_perl/IO...', 'connect', 'connect', 'Connection timed out') called at /opt/perl/lib/vendor_perl/CPS/Future.pm line 312 CPS::Future::_mark_ready('CPS::Future=HASH(0x18080f0)') called at /opt/perl/lib/vendor_perl/CPS/Future.pm line 405 CPS::Future::fail('CPS::Future=HASH(0x18080f0)', 'connect: Connection timed out', 'connect', 'connect', 'Connection timed out') called at /opt/perl/lib/vendor_perl/IO/Async/Connector.pm line 206 IO::Async::Connector::__ANON__[/opt/perl/lib/vendor_perl/IO/Async/Connector.pm:215]() called at /opt/perl/lib/vendor_perl/CPS/Governor.pm line 54 CPS::Governor::enter('CPS::Governor::Simple=HASH(0x1863d40)', 'CODE(0x19dc9b8)', 'CODE(0x18048e8)', 'CODE(0x17e0518)') called at /opt/perl/lib/vendor_perl/CPS.pm line 188 CPS::gkloop(undef) called at /opt/perl/lib/vendor_perl/IO/Async/Loop/Poll.pm line 163 IO::Async::Loop::Poll::post_poll('IO::Async::Loop::Poll=HASH(0x17dd0f0)') called at /opt/perl/lib/vendor_perl/IO/Async/Loop/Poll.pm line 237 IO::Async::Loop::Poll::loop_once('IO::Async::Loop::Poll=HASH(0x17dd0f0)', undef) called at /opt/perl/lib/vendor_perl/IO/Async/Loop.pm line 457 IO::Async::Loop::run('IO::Async::Loop::Poll=HASH(0x17dd0f0)') called at ./test.pl line 42 Perl v5.14.2 under linux Modules in memory: Async::MergePoint v0.04; AutoLoader v5.71; base v2.16; bytes v1.04; Carp v1.20; Config; constant v1.21; CPS v0.17; CPS::Future v0.17; CPS::Governor v0.17; CPS::Governor::Simple v0.17; DynaLoader v1.13; Encode v2.42_01; Encode::Alias v2.13; Encode::Config v2.05; Encode::Encoding v2.05; Encode::Internal; Encode::utf8; Encode::UTF_EBCDIC; Errno v1.13; Exporter v5.64_03; Exporter::Heavy v5.64_03; Fcntl v1.11; HTTP::Headers v6.00; HTTP::Message v6.03; HTTP::Request v6.00; HTTP::Request::Common v6.03; HTTP::Request::SUPER; HTTP::Response v6.03; HTTP::Status v6.03; integer v1.00; IO v1.25_04; IO::Async::Channel v0.53; IO::Async::Connector v0.53; IO::Async::Function v0.53; IO::Async::Function::SUPER; IO::Async::Function::Worker; IO::Async::Handle v0.53; IO::Async::Internals::TimeQueue; IO::Async::Internals::TimeQueue::Elem; IO::Async::Loop v0.53; IO::Async::Loop::Poll v0.53; IO::Async::Notifier v0.53; IO::Async::OS v0.53; IO::Async::Process v0.53; IO::Async::Protocol v0.53; IO::Async::Protocol::Stream v0.53; IO::Async::Protocol::Stream::SUPER; IO::Async::Protocol::SUPER; IO::Async::Resolver v0.53; IO::Async::Resolver::SUPER; IO::Async::Routine v0.53; IO::Async::Stream v0.53; IO::Async::Timer v0.53; IO::Async::Timer::Countdown v0.53; IO::Async::Timer::Countdown::SUPER; IO::Async::Timer::SUPER; IO::File; IO::Handle v1.31; IO::Poll v0.08; IO::Socket v1.32; IO::Socket::INET v1.31; IO::Socket::SUPER; IO::Socket::UNIX v1.23; List::Util v1.23; Module::Versions::Report v1.06; Net::Async::HTTP v0.17; Net::Async::HTTP::Protocol v0.17; Net::Async::HTTP::Protocol::SUPER; Net::Async::HTTP::SUPER; Net::Async::HTTP::Timer v0.17; overload v1.13; POSIX v1.24; POSIX::SigRt; Scalar::Util v1.23; SelectSaver v1.02; Socket v2.006; Storable v2.27; strict v1.04; Sub::Name v0.05; Symbol v1.07; Tie::Hash v1.04; Time::HiRes v1.972101; URI v1.59; URI::_generic; URI::_punycode v0.04; URI::_server; URI::_server::SUPER; URI::Escape v3.31; URI::http; vars v1.02; warnings v1.12; warnings::register v1.02; XSLoader v0.13;
Hi there, The timeout logic has been rewritten quite a bit since this version. Can you retest on latest (0.25) and see if it still happens? -- Paul Evans
$ time perl -Mblib examples/GET.pl --timeout 5 http://127.0.0.20/ Failed - Timed out Timed out at examples/GET.pl line 39. real 0m5.197s user 0m0.164s sys 0m0.024s Timeout logic looks fine to me (0.34). Closing ticket. -- Paul Evans