in reply to LWP::UserAgent Get timing out after few request

Without being able to test or read the API docs I would suggest uncommenting your sleep and raising it from 3 to 5 or even 10. Also, setting $ua->timeout(120) or something in case it's just the service bogging down under any load Missed that you already had a much higher one. Might not be the case but it is possible to configure unlimited GETs while restricting the frequency or amount of data transferred.

Replies are listed 'Best First'.
Re^2: LWP::UserAgent Get timing out after few request
by sannag (Sexton) on Aug 17, 2017 at 15:44 UTC
    Thanks but had not luck I increased the sleep time to 10 and 15 made no difference. Also played around with timeout (both increasing and decreasing seem to make no difference)

      Is this a public API that any of us could play with or something closed or paid?

        unfortunately it is an closed API (else I would have gladly posted the URL)...on another note I tried using the REST::Client instead of LWP::UserAgent and it worked that is it did not time out.

        sub getUserInfov { my($userId) = @_; my $userURI = 'https://xxx.com/api/m1/request/'. $partnerId. '/users/ + print $userURI, "\n"; my $client = REST::Client->new(); $client->addHeader('Authorization', $authHeaders); $client->GET($userURI); # my $userContent = decode_json( $client->responseContent()); # print Dumper($userContent); print 'Response: ' . $client->responseContent() . "\n"; print 'Response status: ' . $client->responseCode() . "\n"; foreach ( $client->responseHeaders() ) { print 'Header: ' . $_ . '=' . $client->responseHeader($_) . "\n"; } # return ($userContent); #sleep (3); }