Getting read timeout error while fetching URL thru LWP

Discussion in 'Perl Misc' started by Prad, Feb 25, 2004.

  1. Prad

    Prad Guest

    Hi,

    I am trying to fetch some URLs using LWP, but keep getting read
    timeout error at times.

    Here is what I am doing.

    Foreach my $url (@urls) {
    my $ua = LWP::UserAgent->new(timeout => 300, agent => 'Mozilla/5.0',
    );
    my $req = new HTTP::Request POST => '$url' ;

    $req->content("...");

    my $content;
    if ($res->is_success)
    {
    $content= $res->content;
    }
    else
    {
    use Data::Dumper;
    print "Request : " ,Dumper $req;
    print "Response : " ,Dumper $res;
    die "Could not get content : Message : " , $res->message;
    }
    }

    The loop runs and works fine for 10-15 urls, and then dies with the
    error : read timeout at d:\perllib\URLBatch.pm

    It doesn't dies consistently at the same URL. If I try to view the URL
    in browser, the URL shows up fine, and well before 300 seconds (the
    timeout).

    I can't figure out, what am I doing wrong.

    Any pointers would be highly appreciated.

    The output from the Dumper statements is below.

    Thanks,

    -Pradeep


    $VAR1 = bless( {
    '_method' => 'POST',
    '_headers' => bless( {
    'user-agent' => 'Mozilla/5.0'
    }, 'HTTP::Headers' ),
    '_uri' => bless( do{\(my $o =
    'http://xyz.com/URLBatchFactory.cgi')}, 'URI::http' ),
    '_content' => 'ProjectID=111&Command=GetDetails'
    }, 'HTTP::Request' );


    $VAR1 = bless( {
    '_request' => bless( {
    '_method' => 'POST',
    '_headers' => bless( {

    'user-agent' => 'Mozilla/5.0'
    },
    'HTTP::Headers' ),
    '_uri' => bless( do{\(my $o =
    'http://xyz.com/URLBatchFactory.cgi')}, 'URI::http' ),
    '_content' =>
    'ProjectID=209Command=GetDetails'
    }, 'HTTP::Request' ),
    '_headers' => bless( {
    'client-date' => 'Mon, 23 Feb
    2004 11:18:20 GMT'
    }, 'HTTP::Headers' ),
    '_msg' => 'read timeout',
    '_rc' => 500,
    '_content' => ''
    }, 'HTTP::Response' );
    Prad, Feb 25, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vinod I
    Replies:
    2
    Views:
    2,195
    Alvin Bruney [MVP]
    Mar 2, 2004
  2. Bhavesh
    Replies:
    1
    Views:
    414
    Bhavesh
    Jul 17, 2007
  3. THTB
    Replies:
    0
    Views:
    184
  4. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,284
    Brian Candler
    Oct 6, 2004
  5. Max Williams
    Replies:
    3
    Views:
    169
    Robert Klemme
    Jan 6, 2009
Loading...

Share This Page