Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

LWP 500 Internal response read timeout

by vhn2000 (Initiate)
on Jun 12, 2013 at 04:09 UTC ( #1038388=perlquestion: print w/replies, xml ) Need Help??

vhn2000 has asked for the wisdom of the Perl Monks concerning the following question:

hi all,
I've read through several similar posts regarding this problem but still haven't been able to find an answer for my situation. I wanted to clarify that my system doesn't have any proxy setting. my system is Linux. So I have a simple program to consume a restful webservice.
#!/usr/local/bin/perl -w use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => $url); ##add some headers here## my $res = $ua->request($req);
When i ran this code, it timed out( i increased timeout still not solving the issue). I was able to consume this url with a PHP script i wrote. I also used other 3rd party restful api(firefox addon, java app) on the same url with no issue. so i took it further by setting up wireshark and ran the perl script. when i looked at the packets, it seemd like all the relevant data was passed back to my system. But some how the LWP library(/usr/local/share/perl5/LWP/Protocol/ at function "can_read") was not able to get the end of message. Below is the Dumper of the Response object and handler from UserAgent.
GET Accept: application/atom+xml Authorization: Basic dsfls;fjal;ksdf== User-Agent: libwww-perl/5.834 Content-Type: application/xml (no content) 500 read timeoutt Content-Type: text/plain Client-Date: Wed, 12 Jun 2013 04:10:56 GMT Client-Warning: Internal response 500 read timeoutt\n 500 read timeoutt Content-Type: text/plain Client-Date: Wed, 12 Jun 2013 04:10:56 GMT Client-Warning: Internal response 500 read timeoutt $VAR1 = bless( { '_content' => '500 read timeoutt ', '_rc' => 500, '_headers' => bless( { 'client-warning' => 'Internal +response', 'client-date' => 'Wed, 12 Jun +2013 04:10:56 GMT', 'content-type' => 'text/plain' }, 'HTTP::Headers' ), '_msg' => 'read timeoutt', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = +'')}, 'URI::http' ), '_headers' => bless( { 'user-a +gent' => 'libwww-perl/5.834', 'conten +t-type' => 'application/xml', 'accept +' => 'application/atom+xml', 'author +ization' => 'Basic a;lsdfjjadfsafadf==' }, 'HTTP: +:Headers' ), '_method' => 'GET', '_uri_canonical' => $VAR1->{'_ +request'}{'_uri'} }, 'HTTP::Request' ) }, 'HTTP::Response' );
Any insights would be greatly appreciated. Thanks!

Replies are listed 'Best First'.
Re: LWP 500 Internal response read timeout
by derby (Abbot) on Jun 12, 2013 at 11:51 UTC

    interesting .. that 500 error message 'read timeoutt' is a rather odd spelling and I expect it's not coming from LWP but from the target server. Sorry I cannot think of a reason off the top of my head, but here's how I would approach the problem:

    • double check the PHP client to ensure you're sending all the info (any missing headers?)
    • if you have access to the target server, check its' logs for clues
    • use a command line client (like curl) to see if you get success or the same error
    • make use of LWP::UserAgent's handlers to better inspect the data. Look at the response_data and response_done handlers -- the wireshark output leads me to believe that some of the data is coming down the pipe (chunked response?) but then the target server throws a 500 so LWP::UserAgent drops the chunks already received (and that my fellow monks is a wild guess!)

      I modified LWP code to print out "timeoutt" just ensure it's coming from LWP. And yes the "transfer-encoding" is "chunked". Again, the timeout message is not from target server.

        There were some issues with certain version of Net::HTTP and chunked responses.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1038388]
Approved by hdb
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2022-06-27 12:05 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (88 votes). Check out past polls.