Will the LWP timeout trigger if some data has been sent, and data communication has been interrupted for x seconds?
I've been using the following code for getting hosted data from a timer controlled field station:
use LWP::Simple;
my $url = 'http://site.com/file.html';
print "Getting\n";
my $content = get $url;
print "Done\n";
The problem is that sometimes it hangs on the get$url, and never comes back
Getting
Done
Getting
Hang
It's an occasional glitch, but hangs my perl script entirely. I believe that the problem is that the webserver that I am collecting data from might be getting powered off before all of the data is sent back to my perl script, so my perl script is hanging for MORE data after getting the starting few bytes.
I have moved to LWP::agent using code ripped from:
#http://www.utsc.utoronto.ca/~harper/cscb09/lecture11.html
use LWP::UserAgent;
use LWP;
$ident = "The Server"; # this gets logged
$timeout = 5; # in seconds
$ua = new LWP::UserAgent; # call the constructor
$ua->agent($ident); # set the id
$ua->timeout($timeout); # timeout
my $req = new HTTP::Request GET => 'http://site.com';
Will the timeout used here timeout even after getting some parts of the data, or will it only timeout if it doesn't get anything?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.