Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

LWP::UserAgent - works on one system, fails on another

by ezekiel (Pilgrim)
on May 29, 2013 at 02:11 UTC ( [id://1035763]=perlquestion: print w/replies, xml ) Need Help??

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

Hello all

I have a simple script (a summary of it below) designed to automate the download of a bunch of files via http. It works fine when I run it from one system but on a second system I get the error message:

500 Status read failed: Connection reset by peer

I'm guessing some sort of proxy/firewall issue that affects the second system but not the first. However, I'm not sure where to start to check what the problem is and then how to correct it?

Thanks for your advice

#! /usr/bin/perl -w use strict; use LWP::UserAgent; my @files = ( "file1.gz", "file2.gz", "file3.gz" ); my $ua = LWP::UserAgent->new(); foreach my $file (@files) { my $url = "http://site.com/directory/" . $file; my $request = new HTTP::Request( GET => "$url" ); my $response = $ua->request($request, $file); if ($response->is_success) { print "Got file $file\n"; } else { die $response->status_line; } }

Replies are listed 'Best First'.
Re: LWP::UserAgent - works on one system, fails on another
by Anonymous Monk on May 29, 2013 at 04:18 UTC

    However, I'm not sure where to start to check what the problem is and then how to correct it?

    Contact your sysadmin? use ps ... among other OS specific tools to check to see if there is a firewall running, selinux ... ?? HTTP::ProxyAutoConfig - use a .pac or wpad.dat file to get proxy information

    HTTP::ProxyPAC - use a PAC (Proxy Auto Config) file to get proxy info

Re: LWP::UserAgent - works on one system, fails on another
by hippo (Bishop) on May 29, 2013 at 14:02 UTC

    Step 1 has to be to check whether any means of establishing an HTTP connection from the bad (second) system to the destination works. Try wget/curl/lynx, etc. If none work, then it is clearly not a perl problem.

    Conversely, if you can get a working HTTP connection from the bad system, it's time to examine the differences between the bad system and the good system. Same O/S? Same version of perl? Same version of LWP?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-19 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found