Piwik 2.11.0 curl_exec Operation timed out – Bug Fix

A server I administer running Piwik 2.11.0 web analytics encountered a problem during an automatic upgrade from Piwik 2.11.0 to Piwik 2.11.1.

The error given after clicking the automatic upgrade link was similar to:

curl_exec: Operation timed out after 9984 milliseconds with 12801064 out of 13344050 bytes received.

Hostname requested was: builds.piwik.org

Close, but no cigar. Curl tries to download the 13 megabyte piwik upgrade archive and nearly succeeds but the default curl timeout stops it just short. On servers with huge bandwidth capacity this is probably never a problem but it’s all about getting the file within the default time limit. With insufficient bandwidth, the timeout is reached before the server can finish downloading.

This issue is fixed by using a longer timeout in the latest version. However, if you’re on version 2.11.0 like I was, it doesn’t fix the immediate problem of running into the curl_exec Operation timeout when you try to automatically upgrade to the latest version.

There is a way around which involves editing one line of one file in your current Piwik install. Remember to back-up both your Piwik installation files and your Piwik database before fiddling with the installed files. Misadventure could lead to a broken installation or worse, loss of your analytics data!

Piwik offers this fix in /piwik/plugins/CoreUpdater/Controller.php: https://github.com/piwik/piwik/commit/76e4378b18b2e24853846c38f7eded956ee0eb57 which indicates that the timeout (in seconds) can be changed from 30 to 120 which appears to be the path before the 2.11.2 release but I was stuck on version 2.11.0 which had line 175 reading:

Http::fetchRemoteFile($url, $this->pathPiwikZip);

I therefore changed this line to read:

Http::fetchRemoteFile($url, $this->pathPiwikZip, 0, 120);

I then saved/re-uploaded the file to the server and re-executed the automatic updater which took me straight to the now current 2.11.2 version.

Job done 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *