in reply to LWP::UserAgent request ignores timeout when internal server error encountered
Hello Anonymous Monk,
Have a look on this previously similar answered question Hard timeout for LWP::UserAgent or similar, as it contains several different approaches to your problem.
Update: I just wrote a very small sample of code that it looks like timeout is working. I do not know why it is not working for you.
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent (); use Time::HiRes qw[ time ]; my $ua = LWP::UserAgent->new; $ua->timeout(1); my $uri = "http://192.168.1.31/noexist.html"; print time . "\n"; my $response = $ua->post($uri); print time . "\n"; if ($response->is_success) { print $response->decoded_content; # or whatever } else { die $response->status_line; } __END__ $ perl test.pl 1534257027.70495 1534257028.72877 500 Can't connect to 192.168.1.31:80 (Connection timed out) at test.pl + line 18.
Hope this helps, BR.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: LWP::UserAgent request ignores timeout when internal server error encountered
by Anonymous Monk on Aug 14, 2018 at 13:58 UTC | |
by hippo (Archbishop) on Aug 14, 2018 at 14:22 UTC |