$c->inactivity_timeout(300);
$ua->connect_timeout(15)->inactivity_timeout(30);
$c->delay(
sub {
$ua->get($url, shift->delay);
},
sub {
my ($delay, $tx) = @_;
$c->render(json => {
url => $tx->req->url->to_string,
err => $tx->error,
});
}
);
[error] SSL connect attempt failed because of handshake problems
[debug] Inactivity timeout.
I think the SSL error prevents the ua from invoking the callback.
Here is a debug output of an example where ua will NEVER complete the request (say dumper($tx) is never executed)
Mojo::Reactor::Poll: Timer a8665afb344a7d4e85fa162c15e77c77 failed: Mojo::UserAgent: Event "timeout" failed: Can't call method "steal_handle" on an undefined value at /usr/local/share/perl/5.14.2/Mojo/UserAgent.pm line 155
But I got another error:Mojo::Reactor::Poll: Timer a8665afb344a7d4e85fa162c15e77c77 failed: Mojo::UserAgent: Event "timeout" failed: Can't call method "steal_handle" on an undefined value at /usr/local/share/perl/5.14.2/Mojo/UserAgent.pm line 155
-- Blocking request (https://HOST/)
-- Connect (https:HOST:443)
-- Client >>> Server (https://HOST/)
CONNECT HOST:443 HTTP/1.1
User-Agent: Mojolicious (Perl)
Connection: keep-alive
Accept-Encoding: gzip
Content-Length: 0
Host: HOST
-- Client <<< Server (https://HOST/)
HTTP/1.1 200 OK
Date: Mon, 11 Aug 2014 07:16:24 GMT
Server: Apache/2.2.8 (Win32) PHP/5.2.6
X-Powered-By: PHP/5.2.6
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
2077
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<some more html>
Mojo::Reactor::EV: Timer 46532da0bf10681d0a1ae8eb98fa1a62 failed: Mojo::UserAgent: Event "timeout" failed: Can't call method "steal_handle" on an undefined value at /Library/Perl/5.16/Mojo/UserAgent.pm line 155, <DATA> line 1.
Here is a debug output for this errorMojo::Reactor::Poll: Timer 8c95563d3ebc122fe9c49b346f16a653 failed: Mojo::UserAgent: Event "timeout" failed: Can't call method "steal_handle" on an undefined value at /usr/local/share/perl/5.14.2/Mojo/UserAgent.pm line 155.
I updated to the lastest version. The "steal_handle" error is gone.
But ...
Here is another example where Mojo::UserAgent never returns (I was expecting an inactivity timeout or a SSL error):-- Blocking request (https://HOST)-- Connect (https:HOST:443)-- Client >>> Server (https://HOST)CONNECT HOST:443 HTTP/1.1User-Agent: Mojolicious (Perl)Connection: keep-aliveAccept-Encoding: gzipContent-Length: 0Host: HOST-- Client <<< Server (https://HOST)HTTP/1.0 200 Connection establishedProxy-agent: CCProxy 6.64
Maybe you can build a test case with malformed SSL responses?
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use Mojo::UserAgent;
use Mojo::Util 'steady_time';
while(<DATA>) {
chomp;
next unless length;
my $p = "http://$_";
say $p;
my $ua = Mojo::UserAgent->new;
$ua->proxy->http($p)->https($p);
my $t = steady_time;
my $tx = $ua->get('https://www.google.com');
$t = sprintf('%.3fs', steady_time - $t);
if($tx->success) {
say "ok: ", $tx->res->code;
} else {
say "fail: ", ($tx->error->{message} // '-');
}
say "time: $t\n";
}
__DATA__
190.102.28.40:80
61.150.76.205:808
60.251.152.85:80
218.92.227.165:17945
183.223.29.120:8123
163.125.207.112:9999I have just built a simple test script.