I have a perl script on a web server that basically relays a Post to another URL. It has been working fine for several months but suddenly now gives an error. It works OK on a different webserver. I have a simplified script that shows the problem, although I have redacted the actual target url and parameters below. I have updated the Perl modules, but to no effect. It consistently gives the error message:
read failed: at /data04/cdc/perl5/lib/perl5/LWP/Protocol/http.pm line 382.
The line in question in http.pm is
my $n = $socket->sysread($buf, 1024, length($buf));
unless (defined $n) {
die "read failed: $!" unless $!{EINTR} || $!{EWOULDBLOCK} || $!{EAGAIN};
I don't know how to go about solving this problem. The hosting company just tell me it is a problem with the 3rd party LWP script which they cannot help me with.
Test script:
#!/usr/bin/perl
use LWP::UserAgent;
my $url = 'https://XXXX/YYYY/';
my @lmargs;
push @lmargs, 'p1', 'v1';
push @lmargs, 'p2', 'v2';
my $ua = LWP::UserAgent->new();
my $response = $ua->post( $url, \@lmargs);
my $resp = $response->decoded_content();
print "Content-Type: text/html\n\n";
print "<html> <head>\n";
print "<title>Hello, world!</title>";
print "</head>\n";
print "<body>\n";
print "<h1>Test 2</h1>\n";
if (! defined $response) { print "<br>No response defined<br>"; }
elsif (! defined $resp) { print "<br>No decoded response defined<br>"; }
else { print "<br>decoded response=$resp<br>"; }
print "</body> </html>\n";
exit;