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

The below code produces an error on Windows 7 Pro, it reads 5-8K bytes of the web page, then terminates:

use strict; use LWP::UserAgent; my $url = 'https://www.flickr.com/photos/71475421@N02/26176178323/'; my $ua = LWP::UserAgent->new; my $res = $ua->get($url); print $res->headers->as_string;
The error is:
X-Died: read failed: A non-blocking socket operation could not be completed immediately. at C:/Perl/lib/LWP/Protocol/http.pm line 467.

OS: Win 7 Pro (64bit)
Perl: 5.20.1 (32bit)
LWP: 6.08
LWP-Protocols-https: 6.06

Any ideas why is it not working, and how it can be fixed?

Thanks.
  • Comment on “Non-blocking socket operation” error in LWP::UserAgent package
  • Download Code

Replies are listed 'Best First'.
Re: “Non-blocking socket operation” error in LWP::UserAgent package
by VinsWorldcom (Prior) on May 03, 2016 at 00:23 UTC

    I think it works for me; that is, I don't get the error you're talking about. I'm on Windows 7 x64, Strawberry 5.18.1 and LWP::UserAgent 6.05 (bundled with Strawberry).

    If I redirect output to a file, the file is 6,085 bytes, starting and ending with:

    Cache-Control: no-cache, max-age=0, must-revalidate, no-store [... output omitted ...] Y-Trace: BA [...] AAA--
      According to the response-header, 6K is too short:
      Content-Length: 246406

        VinsWorldcom is reporting the length of the headers (because that's what your script outputs) not the length of the payload.

Re: “Non-blocking socket operation” error in LWP::UserAgent package
by Anonymous Monk on May 03, 2016 at 00:13 UTC

    Any ideas why is it not working, and how it can be fixed?

    Standard answer is upgrade your LWP and all its dependencies

    You say you have LWP: 6.08 and that is about two years old

    After you have upgraded try again and see what happens :)

      According to PPM, these are the newest packages available. :(

        According to PPM, these are the newest packages available. :(

        use cpan, cpanp, cpanm, to install modules, esp pure perl modules like LWP