sannag has asked for the wisdom of the Perl Monks concerning the following question:
**************
I don't the underlying cause. I fixed the issue on my program by using REST::Client instead of LWP::UserAgent....details of the code are in one of my reply below
***************
My Get request is timing out after processing 20 or 30 request...I have over 500 records to process. I did confirm that there is no limit on number of GET requested placed to API. I also tried using chrom extension postman to repeatably place GET request successfully. Yet when I place GET request though my perl program it failed after processing few requests. Any help is greatly appreciated
error says following:
500 can't connect to api.xxx.com:443. (A connection attempt failed because the connected party did not properly respond after a periold of time, or established connection failed because connected host has failed to respond
LWP::Protoclo::https::Socket: connect: a connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond at C:/Dwimperl/perl/site/LWP/Protocol/http.pm"
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, ); $ua->timeout('1000'); sub getUserInfo { my($userId) = @_; my $partnerId = 'B53765B23456678C1' my $userURI = 'https://xxx.com/api/m1/request/'. $partnerId. '/users/ +'. $userId; print $userURI, "\n"; #sleep (3); my $userResponse = $ua -> request(GET($userURI, Authorization => $aut +hHeaders)); # I am getting a token which is passed in the header. if ($userResponse->is_success) { my $userRecord = decode_json($userResponse->content); print $userResponse->status_line, "\n"; return ($userRecord); } else { displayMsg ( "No user Records to process...................."); print $userResponse->status_line, "\n"; print $userResponse->decoded_content, "\n"; error ("Error: ", $userResponse->status_line, " " , $userResponse- +>decoded_content); exit 1; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: LWP::UserAgent Get timing out after few request
by Your Mother (Archbishop) on Aug 17, 2017 at 15:33 UTC | |
by sannag (Sexton) on Aug 17, 2017 at 15:44 UTC | |
by Your Mother (Archbishop) on Aug 17, 2017 at 15:48 UTC | |
by sannag (Sexton) on Aug 17, 2017 at 16:07 UTC | |
Re: LWP::UserAgent Get timing out after few request
by Mr. Muskrat (Canon) on Aug 17, 2017 at 15:33 UTC | |
by Your Mother (Archbishop) on Aug 17, 2017 at 15:35 UTC | |
by Mr. Muskrat (Canon) on Aug 17, 2017 at 16:22 UTC |