Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Can't locate object method "new" via package "LWP::Protocol::https::Socket"

by Philbert (Novice)
on Jul 08, 2022 at 17:24 UTC ( [id://11145359]=perlquestion: print w/replies, xml ) Need Help??

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

I'm running Strawberry Perl 5.32.1.1 (64bit) on Windows Server 2019 and I'm unable to use XMLRPC::Lite to make HTTPS requests. Code previously ran with no trouble on what's now an ancient ActivePerl 32bit installation.

Can't locate object method "new" via package "LWP::Protocol::https::Socket"

I'm not exactly an advanced Perler. I updated all sorts of modules, and took a peek inside LWP/Protocol/https.pm , but I haven't really learned anything other than LWP::Protocol::https::Socket is defined in https.pm and.. it must be inheriting everything because it doesn't define a new() of its own..?
use XMLRPC::Lite; $xmlrpc = XMLRPC::Lite->proxy('https://server/path'); $xmlrpc->transport()->ssl_opts( verify_hostname => 0 ); my $call = $xmlrpc->call( 'RPC.method', 'password', 'someParam');
  • Comment on Can't locate object method "new" via package "LWP::Protocol::https::Socket"
  • Download Code

Replies are listed 'Best First'.
Re: Can't locate object method "new" via package "LWP::Protocol::https::Socket"
by hv (Prior) on Jul 08, 2022 at 18:05 UTC

    From https.pm:

    use base qw(Net::HTTPS LWP::Protocol::http::SocketMethods);

    This tells us that it uses those as "base" classses, inheriting methods from them.

    In HTTPS.pm from the Net::HTTPS package it runs through some hoops to decide an appropriate socket class $SSL_SOCKET_CLASS, and then has:

    our @ISA=($SSL_SOCKET_CLASS, 'Net::HTTP::Methods');

    which is another way of achieving something similar to use base.

    The choices for the $SSL_SOCKET_CLASS are IO::Socket::SSL or Net::SSL, so you need to have at least one of those installed for it to work (and provide a new() function).

    Does that help you get any further?

Re: Can't locate object method "new" via package "LWP::Protocol::https::Socket"
by kcott (Archbishop) on Jul 08, 2022 at 18:11 UTC

    G'day Philbert,

    Welcome to the Monastery.

    I'm making something of a guess here, based on fairly recent issues I encountered with LWP::Protocol::https (LWP::Protocol::https::Socket is bundled with this — see the distribution page), and your "ancient ActivePerl 32bit installation".

    The third paragraph of the "LWP::Protocol::https DESCRIPTION" starts with:

    "This module used to be bundled with the libwww-perl, but it was unbundled ..."

    The solution to my problems, a year or two ago, was to install LWP::Protocol::https. This may also work for you. It's possible that you may need to update other modules (e.g. XMLRPC::Lite) but that's also a guess.

    — Ken

Re: Can't locate object method "new" via package "LWP::Protocol::https::Socket"
by Philbert (Novice) on Jul 08, 2022 at 19:21 UTC

    Thank you, o wise ones. I was expecting a bit more condescension.

    In response to both replies, when I attempt to install/update, the CPAN shell tells me:

    • IO::Socket::SSL is up to date (2.074).
    • Net::SSL is up to date (2.86).
    • LWP::Protocol::https is up to date (6.10).
    • XMLRPC::Lite is up to date (0.717).

      I might be obscuring things by troubleshooting XMLRPC::Lite when I could be troubleshooting LWP.

      use LWP::UserAgent; use HTTP::Request::Common; $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; my ($response_content, $response_status); my $userAgent = LWP::UserAgent->new(); $userAgent->agent("PhilPerl"); my $request = HTTP::Request->new(); $request->method('GET'); $request->uri('https://perlmonks.org'); my $response = $userAgent->request($request);

      Gets me a $response that seems more helpful. The gist of which is:

      Can't load 'C:/Strawberry/perl/site/lib/auto/Net/SSLeay/SSLeay.xs.dll' for module Net::SSLeay: load_file:The specified module could not be found (LWP::Protocol::https not installed)

      But I do have a C:\Strawberry\perl\site\lib\auto\Net\SSLeay\SSLeay.xs.dll so I'm not sure what to make of that.

        Can't load 'C:/Strawberry/perl/site/lib/auto/Net/SSLeay/SSLeay.xs.dll' for module Net::SSLeay: load_file:The specified module could not be found (LWP::Protocol::https not installed)

        The (second) script that you provided works fine for me on 64-bit Strawberry Perl 5.32.1.1. I'm therefore pretty certain that there's something broken in your environment - perhaps some interference from some old perl installation.

        I think you should be able to reproduce that error by simply trying to "use Net::SSLeay" :
        perl -MNet::SSLeay -e 1
        I added a bit to your script, to reveal the contents of $response:
        use LWP::UserAgent; use HTTP::Request::Common; $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; my ($response_content, $response_status); my $userAgent = LWP::UserAgent->new(); $userAgent->agent("PhilPerl"); my $request = HTTP::Request->new(); $request->method('GET'); $request->uri('https://perlmonks.org'); my $response = $userAgent->request($request); if ($response->is_success) { print $response->decoded_content; } else { die $response->status_line; }
        For me, that worked fine and successfully retrieved the requested page.

        Even if I effectively remove LWP::Protocol::https (by renaming perl/vendor/lib/LWP/Protocol/https.pm to perl/vendor/lib/LWP/Protocol/https.pm_hide) the script still runs fine.
        However, in this instance, $response merely contains the message "501 Protocol scheme 'https' is not supported (LWP::Protocol::https not installed) at try.pl line 21."

        In addition to the checks already mentioned, take a look at what's in your PATH (perl -le "print $ENV{PATH}) as that's what SSLeay.xs.dll searches (in sequence) for the dlls it needs.
        And it will load the first one it finds whose name (case-insensitively) matches the name it's looking for.

        Your SSLeay.xs.dll needs to load msvcrt.dll, kernel32.dll, libcrypto-1_1-x64__.dll, libssl-1_1-x64__.dll and perl532.dll.
        The first 2 are system files - there should be no problem there.
        The last one is the perl-5.32.x dll - there should be no problem there unless there's another perl532.dll found earlier in the path.
        And the remaining 2 are given such StrawberryPerl-specific names that it's very unlikely there's a problem there.
        It's a bit of a mystery !!

        Cheers,
        Rob

        Here's some troubleshooting tips. You'll need to make a few adjustments for your MSWin vs. my Cygwin: double quotes around perl commands springs to mind; there may be others.

        If cpan is telling you "LWP::Protocol::https is up to date", but perl is telling you "LWP::Protocol::https not installed", that generally suggests you're running different versions. They should be in the same directory:

        $ which perl /home/ken/perl5/perlbrew/perls/perl-5.36.0/bin/perl $ which cpan /home/ken/perl5/perlbrew/perls/perl-5.36.0/bin/cpan

        Check what's in @INC:

        $ perl -E 'say for @INC' /home/ken/perl5/perlbrew/perls/perl-5.36.0/lib/site_perl/5.36.0/cygwin +-thread-multi /home/ken/perl5/perlbrew/perls/perl-5.36.0/lib/site_perl/5.36.0 /home/ken/perl5/perlbrew/perls/perl-5.36.0/lib/5.36.0/cygwin-thread-mu +lti /home/ken/perl5/perlbrew/perls/perl-5.36.0/lib/5.36.0

        perl -V will give you that information and a lot more. There could be something useful in that output.

        Try to load just the module:

        $ perl -e 'use LWP::Protocol::https'

        That will just return (no output) on success or you might get "Can't locate LWP/Protocol/https.pm in @INC ...".

        If that was successful, get more information:

        $ perl -E 'use LWP::Protocol::https; say $LWP::Protocol::https::VERSIO +N; say $INC{"LWP/Protocol/https.pm"}' 6.10 /home/ken/perl5/perlbrew/perls/perl-5.36.0/lib/site_perl/5.36.0/LWP/Pr +otocol/https.pm

        Note that last line of output should match a directory in @INC obtained earlier. In my case:

        /home/ken/perl5/perlbrew/perls/perl-5.36.0/lib/site_perl/5.36.0

        See how you go with those. A solution might present itself. If still stumped, post all output from those commands and we can look into it further.

        — Ken

        I suspect it's actually referring to a library linked by SSLeay.xs.dll.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-18 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found