Updates check with cURL error 7 and ipv6

Updates check with cURL error 7 and ipv6

by Евгений Сибирцев -
Number of replies: 13

After updating to 2.4 have this on updates check:

Debug info: cURL error 7: Failed to connect to 2400:cb00:2048:1::8d65:70b3: Network is unreachable
Error code: err_response_curl
Stack trace:
  • line 832 of /lib/pluginlib.php: available_update_checker_exception thrown
  • line 718 of /lib/pluginlib.php: call to available_update_checker->get_response()
  • line 481 of /admin/index.php: call to available_update_checker->fetch()

It looks like IP address is in ipv6 format. Our servers doesn't support ipv6 (administrators told me this). How can i switch back to using ipv4 for checking updates?

Average of ratings: -
In reply to Евгений Сибирцев

Re: Updates check with cURL error 7 and ipv6

by Ken Task -
Picture of Particularly helpful Moodlers

Judging from strack trace looks like a Linux boxen.

Googling ... found this:

http://www.businesscorner.co.uk/disable-ipv6-in-curl-and-php/

From command line as root user:

curl-config --features

Just did a git update and checked for updates on 2.4.3+ (Build: 20130328) and didn't see any issues.

'spirit of sharing', Ken

In reply to Ken Task

Re: Updates check with cURL error 7 and ipv6

by Евгений Сибирцев -

Today i updated to Moodle 2.4.3+ (Build: 20130328) and error is still here.

Is any way to force Moodle use ipv4, because i think it will be more harder to force our admins to change curl (i gave them link from the previous post two weeks ago and they do nothing).

In reply to Евгений Сибирцев

Re: Updates check with cURL error 7 and ipv6

by Matt Spurrier -

What's actually happening here, is that your server is configured to use ipv6, but has not got the gateway and transport in order to connect successfully, as such, your operating system attempts to connect over ipv6, and then fails.

Configuration does exist to disable IPv6 at the OS level, or you may disable it at php/curl's level. in RHEL/CentOS etc, the OS level is configured in /etc/sysconfig/network by the variable NETWORKING_IPV6=<yes|no>

If I recall correctly, it explicitly has to be set to no and the network service restarted.

I am not having any problems connecting to our servers from an IPv4-Only node with NETWORKING_IPV6=no.

Hope that helps.

Matt

Average of ratings: Useful (2)
In reply to Matt Spurrier

Re: Updates check with cURL error 7 and ipv6

by Евгений Сибирцев -

Our admins try to disable ipv6 in OS (turn off protocol services).

After this i have another error:

Debug info: cURL error 28: connect() timed out!
Error code: err_response_curl
Stack trace:
  • line 832 of /lib/pluginlib.php: available_update_checker_exception thrown
  • line 718 of /lib/pluginlib.php: call to available_update_checker->get_response()
  • line 481 of /admin/index.php: call to available_update_checker->fetch()
In reply to Евгений Сибирцев

Re: Updates check with cURL error 7 and ipv6

by Евгений Сибирцев -

We turn service on, because some other programs began to log errors.

So we are again with error discribed in first post.

In reply to Евгений Сибирцев

Re: Updates check with cURL error 7 and ipv6

by Simon Story -

Hello,

Maybe if you put

141.101.112.179 download.moodle.org

In your /etc/hosts file. This is a hack, but it may solve your problem.

And make sure your webserver can access download.moodle.org on ports 80 and 443.

In reply to Simon Story

Re: Updates check with cURL error 7 and ipv6

by Matt Spurrier -

Unfortunately due to the technology used with cloudflare, this may not work too well. cloudflare uses latency based dns routing, so depending on where you are in the world, these IPs will be different.

In addition to that consideration, if they pull the address out of rotation or reassign it to a different service, your access may stop working, as such, I would highly recommend against this.

In reply to Евгений Сибирцев

Re: Updates check with cURL error 7 and ipv6

by Matt Spurrier -

That's rather odd, it tends to indicate that you have bigger problems.

Could you try turning IPv6 off in your kernel?

in /etc/sysctl.conf modify the following settings:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

once you've edited these settings, run sysctl -p to make them live.

(For the purpose of keeping the old settings to restore to later, simply comment out the old lines by adding # at the start of the line, then paste these lines in)

In reply to Matt Spurrier

Re: Updates check with cURL error 7 and ipv6

by Евгений Сибирцев -

After another week our admins told, that they cant do anything to help me sad

 

So i'd be very happy if anyone tell my how i can edit moodle files to solve this problem.

p.s. it's not so cruel because i can check updates manualy...

 

p.p.s. I found this function: curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );

Can it be helpful? Where should i insert it and what write instead $ch?

In reply to Евгений Сибирцев

Re: Updates check with cURL error 7 and ipv6

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

I was having difficulty downloading the language packs on a shared hosting server so I did not have access to /etc/hosts. I decided to give this suggestion a try and forced it to use v4 by adding:

$options['CURLOPT_IPRESOLVE'] = CURL_IPRESOLVE_V4;

to the download_file_content function. The logical place was around line 1247 (Moodle 2.7) resulting in:

   $options['CURLOPT_RETURNTRANSFER'] = true;
    $options['CURLOPT_NOBODY'] = false;
    $options['CURLOPT_TIMEOUT'] = $timeout;
    $options['CURLOPT_IPRESOLVE'] = CURL_IPRESOLVE_V4;

after doing that I was able to see the list of languages and successfully install a language pack. Peace -Anthony

Average of ratings: Useful (2)
In reply to Anthony Borrow

Re: Updates check with cURL error 7 and ipv6

by Phil Brown -
This works, for anyone who wants to use Moodle on shared hosting services without root access (such as bluehost/godaddy/strato)


located in moodle --> lib --> filelib.php


You can download the file and edit it with an editor, I used sublimed, then upload and overwrite. Should be able to download the languages after that through the Moodle installer.

In reply to Matt Spurrier

Re: Updates check with cURL error 7 and ipv6

by Tulio Nogueira -

Hi!

Sorry for bringing back an old topic...

I disabled ipv6 configuration as suggested by Matthew and still did not work. We still get the error:

Debug info: cURL error 7: Failed to connect to 2400:cb00:2048:1::8d65:71b3: Network is unreachable
Error code: err_response_curl
Stack trace:
  • line 1175 of /lib/pluginlib.php: available_update_checker_exception thrown
  • line 1061 of /lib/pluginlib.php: call to available_update_checker->get_response()
  • line 543 of /admin/index.php: call to available_update_checker->fetch()

Moodle 2.5.2+ (Build: 20130927) on Ubuntu 12.04LTS

With this problem, we cannot check for updates, install language packs...

Any ideas?

 

In reply to Tulio Nogueira

Re: Updates check with cURL error 7 and ipv6

by Ken Task -
Picture of Particularly helpful Moodlers

Even though it's recommended NOT to do this ... might give it a shot ... knowing that one might have to re-edit and research again:

dig AAAA download.moodle.org

from my location I get:

download.moodle.org.    300    IN    AAAA    2400:cb00:2048:1::8d65:70b3
download.moodle.org.    300    IN    AAAA    2400:cb00:2048:1::8d65:71b3

Your location may show something different.

Edit the /etc/hosts file and add one or both of the above to the file:

2400:cb00:2048:1::8d65:70b3 download.moodle.org

Since this is DNS related, consider adding (on a temporary basis) Google's DNS servers (IPV6):

nameserver 2001:4860:4860::8888

nameserver 2001:4860:4860::8844

Make them first in the DNS servers listing.  No reboot/restart of services is needed so just TIA (try it again!).

If successful, might consider commenting those lines out with # in front of them.   That way they are there should they be needed again.   Probably should check with dig again.

'spirit of sharing', Ken