in reply to Re^4: Error 500 in LWP
in thread Error 500 in LWP

https://www.microsoft.com/uk-ua/

So, I see you have changed the target URL again. I wonder why. Anyway, here, on CentOS 6 is the script which works absolutely perfectly for me:

use strict; use warnings; use Test::More tests => 1; use LWP::UserAgent; use Data::Dumper; my $ua = LWP::UserAgent->new; my $res = $ua->get ('https://www.microsoft.com/uk-ua/'); is ($res->code, 200, 'Download succeeded'); diag (qq# LWP: $LWP::VERSION IO::Socket::SSL: $IO::Socket::SSL::VERSION#);

Which gives:

$ perl sslms.pl 1..1 ok 1 - Download succeeded # # LWP: 5.833 # IO::Socket::SSL: 1.31

Replies are listed 'Best First'.
Re^6: Error 500 in LWP
by YarNik (Sexton) on Aug 19, 2017 at 08:52 UTC
    Yes, I changed a little, because I'm looking for a working code.

    Here is a new code where Google returns a different code.

    use strict; use warnings; use LWP::UserAgent; my @hostnames = ( 'http://google.com', 'https://google.com', 'http://microsoft.com', 'https://microsoft.com', 'http://bing.com', 'https://bing.com', ); my $ua = LWP::UserAgent->new; for my $host (@hostnames) { my $res = $ua->get ($host); print $res->code . ' => ' . $res->status_line . "\n"; } print "LWP: $LWP::VERSION\n"; print "IO::Socket::SSL: $IO::Socket::SSL::VERSION\n";
    It returns:
    200 => 200 OK 500 => 500 Can't connect to google.com:443 (connect: Network is unreac +hable) 500 => 500 Can't connect to www.microsoft.com:443 (connect: Network is + unreachable) 500 => 500 Can't connect to www.microsoft.com:443 (connect: Network is + unreachable) 200 => 200 OK 200 => 200 OK LWP: 5.833 IO::Socket::SSL: 1.31

      Well, donning my deerstalker and poring through these extra datapoints I see a pattern emerging. Your client is unable to connect to a URL when using both HTTPS and IPv6. google.com and www.microsoft.com both have IPv6 addresses but bing.com does not (bad bing!). Only you can test this further by adding more data to the set.

      You could try to "fix" this by pre-loading IO::Socket::SSL with the appropriately restrictive option:

      use IO::Socket::SSL 'inet4'; use LWP::UserAgent;

      ... but the real fix is to talk to your systems administrator and have them sort out the problem with your IPv6 connectivity.

        200 => 200 OK 200 => 200 OK 200 => 200 OK 200 => 200 OK 200 => 200 OK 200 => 200 OK LWP: 5.833 IO::Socket::SSL: 1.31
        Perfectly! Thanks you.

        In this case it's a dedicated server and I'm root. Hosting support did not solve the problem, because the error is not theirs and access by wget is good. Maybe you know what to check on the server to fix the error?

        Upd: My hosting company not support IPv6...