I am using HTTP::Tiny + IO::Socket::Socks::Wrapper to send a HTTP Request over a SOCKS Proxy. Everything is working fine except the timeout option. When using only IO::Socket::Socks without HTTP::Tiny the timeout is working.
Example without HTTP::Tiny and a non existent proxy to trigger a timeout:
my $t = time;
my $sock = IO::Socket::Socks->new(
ProxyAddr => '4.5.6.7',
ProxyPort => 1080,
ConnectAddr => 'www.google.com',
ConnectPort => 80,
Timeout => 3
) or print "connection failed or timed out\n";
print "time: " . (time - $t) . "\n";
Output:
connection failed or timed out
time: 3.00517201423645
Example with HTTP::Tiny:
my $t = time;
my $http = wrap_connection(
HTTP::Tiny->new(timeout => 3), {
ProxyAddr => '4.5.6.7',
ProxyPort => 1080,
Timeout => 3
}
);
my $r = $http->get("http://www.google.com");
print "connection failed or timed out\n" unless $r->{success};
print "time: " . (time - $t) . "\n";
Output:
connection failed or timed out
time: 21.0282030105591
Why does the second example not timeout after 3 seconds?
It was bug, which now seems to be fixed. New version will be uploaded to CPAN soon. And right now you can get fixed version from github repo.