Dear monks, my script has to fetch some data from web, the mechanism looks like this:
I run this script on a server (with cron job). The URL is always the same. Sometimes I got en error, variable $text contains: read timeout at /usr/local/share/perl5/Net/HTTP/Methods.pm line 268. Other runs are OK, so I am not sure what the problem is and how to avoid it. Thanks for help! EDIT: Thank you for all replies! I haven't reported any other problems so far. The problem was probably not in the Perl script.for my $try (1 .. 5) { debug("fetching HTML source: try $try of 5\n") if $debug; my $mech = WWW::Mechanize->new( autocheck => 0, ssl_opts => { verify_hostname => 0, SSL_version => 'TLSv1', }, timeout => 60, ); $mech->proxy('https', $args_hr->{proxy}); # Try::Tiny try { $mech->get( $url ); } catch { $err .= $_ if $_; }; my $text = $mech->content; $err .= "Can't fetch HTML source from $url!\n" if !$mech->s +uccess(); ... sleep 30; # before next try - if download was not succ. }
In reply to Occasional Read Timeout with Mech by pirkil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |