Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^6: Error 500 in LWP

by YarNik (Sexton)
on Aug 19, 2017 at 08:52 UTC ( [id://1197650]=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^7: Error 500 in LWP
by hippo (Bishop) on Aug 19, 2017 at 09:12 UTC

    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...

        Hosting support did not solve the problem, because the error is not theirs and access by wget is good.

        wget silently falls back to IPv4 if IPv6 fails. You can demonstrate this by forcing it to use IPv6 only:

        $ wget -6 https://www.microsoft.com/
        Maybe you know what to check on the server to fix the error?

        Maybe IPv6 networking isn't enabled at all or no global scope address has been assigned or there is no default route set up or ...

        You will have to work with your hosting provider to determine the correct configuration details to use.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1197650]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-19 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found