【问题标题】:LWP read fail errorLWP 读取失败错误
【发布时间】:2012-01-29 16:55:42
【问题描述】:

我正在使用 LWP::UserAgent 进行简单的 HTTP Post 并得到以下错误。在网上搜索了很多之后,似乎有一段时间以前修复了一个错误。我的 6.03 版本应该是固定的。关于为什么会发生这种情况的任何想法?

'_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

这是代码示例:

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);

【问题讨论】:

  • 能否提供一个小代码示例来演示如何引发错误。
  • 当我运行此代码 (LWP::UserAgent::VERSION 6.03) 时,一切正常。
  • 嗯,我检查了所有依赖包都是最新的。可能是盒子有问题?
  • 我偶然找到了解决方案。我缺少 IO::Socket::SSL。我在尝试安装 Furl::HTTP 时发现了这一点,它写得很聪明,可以准确地告诉我哪里出了问题。为正确的错误消息欢呼。
  • LWP-Protocol-https requires IO::Socket::SSL,所以这意味着你没有正确安装它/没有正确执行依赖包的检查。

标签: perl lwp-useragent


【解决方案1】:

确保您拥有IO::Socket::SSL 的最新版本,所需的版本 (1.38) 还不够(我刚刚安装了 1.54,似乎可以正常工作)。

https://metacpan.org/source/GAAS/LWP-Protocol-https-6.03/Makefile.PL - 现在已经发布,依赖于 1.54 - 所以希望这能解决问题。

【讨论】:

    猜你喜欢
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 2013-07-29
    • 2015-07-23
    • 1970-01-01
    • 2021-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多