LWP read fail error

5k views Asked by At

I am using LWP::UserAgent to do a simple HTTP Post and get the error below. After much searching online it seems that there was a bug some time back that was fixed. My version 6.03 should be fixed. Any ideas on why this is happening?

'_content' => 'read failed:  at /usr/local/share/perl/5.10.1/Net/HTTP/Methods.pm line 256
 at /usr/local/lib/perl/5.10.1/Net/SSL.pm line 211
        Net::SSL::die_with_error(\'LWP::Protocol::https::Socket=GLOB(0x8d9aa38)\', \'read failed\') called at /usr/local/lib/perl/5.10.1/Net/SSL.pm line 224
        Net::SSL::read(\'LWP::Protocol::https::Socket=GLOB(0x8d9aa38)\', \'\', 1024, 0) called at /usr/local/share/perl/5.10.1/Net/HTTP/Methods.pm line 256
        Net::HTTP::Methods::my_readline(\'LWP::Protocol::https::Socket=GLOB(0x8d9aa38)\', \'Status\') called at /usr/local/share/perl/5.10.1/Net/HTTP/Methods.pm line 343
        Net::HTTP::Methods::read_response_headers(\'LWP::Protocol::https::Socket=GLOB(0x8d9aa38)\', \'laxed\', 1, \'junk_out\', \'ARRAY(0x8cd3d98)\') called at /usr/local/share/perl/5.10.1/LWP/Protocol/http.pm line 378

Here is the code sample:

use LWP::UserAgent;
use Data::Dumper;

my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;

my $response = $ua->get('https://metacpan.org/module/LWP::UserAgent');
print Dumper($response);
1

There are 1 answers

0
Ranguard On

Make sure you have a recent version of IO::Socket::SSL the required version (1.38) is not enough (I've just installed 1.54 which seems to work fine).

https://metacpan.org/source/GAAS/LWP-Protocol-https-6.03/Makefile.PL - this has now been released with a dependency on 1.54 - so hopefully that will sort stuff out.