GeoIPAutoUpdater error


(kkretsch) #1

Since the last update I think the automatic geoIPupdate fails (error lines at the end).

It seems it doubles the “.dat.” part of the extracted file and uses a wrong basename:
failed to unzip '/var/www/stat/misc/GeoIPCity.dat.dat.gz
after downloading ‘http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

ERROR UserCountry[2015-08-12 00:00:48] /var/www/stat/plugins/UserCountry/GeoIPAutoUpdater.php(161): GeoIPAutoUpdater: failed to unzip ‘/var/www/stat/misc/GeoIPCity.dat.dat.gz’ after downloading ‘http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz’: The downloaded file is not a valid GeoIP database. Please re-check the URL or download the file manually.
#0 /var/www/stat/plugins/UserCountry/GeoIPAutoUpdater.php(96): Piwik\Plugins\UserCountry\GeoIPAutoUpdater->downloadFile(‘loc’, ‘http://geolite…’)
#1 [internal function]: Piwik\Plugins\UserCountry\GeoIPAutoUpdater->update(NULL)
#2 /var/www/stat/core/Scheduler/Scheduler.php(227): call_user_func(Array, NULL)
#3 /var/www/stat/core/Scheduler/Scheduler.php(124): Piwik\Scheduler\Scheduler->executeTask(Object(Piwik\Plugins\UserCountry\GeoIPAutoUpdater))
#4 /var/www/stat/plugins/CoreAdminHome/API.php(48): Piwik\Scheduler\Scheduler->run()
#5 /var/www/stat/core/CronArchive.php(449): Piwik\Plugins\CoreAdminHome\API->runScheduledTasks()
#6 /var/www/stat/core/CronArchive.php(268): Piwik\CronArchive->runScheduledTasks()
#7 /var/www/stat/core/Access.php(456): Piwik\CronArchive->Piwik{closure}()
#8 /var/www/stat/core/CronArchive.php(270): Piwik\Access::doAsSuperUser(Object(Closure))
#9 /var/www/stat/plugins/CoreConsole/Commands/CoreArchiver.php(27): Piwik\CronArchive->main()
#10 /var/www/stat/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(257): Piwik\Plugins\CoreConsole\Commands\CoreArchiver->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/stat/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/stat/vendor/symfony/console/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Application->doRunCommand(Object(Piwik\Plugins\CoreConsole\Commands\CoreArchiver), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 [internal function]: Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/stat/core/Console.php(79): call_user_func(Array, Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/stat/core/Access.php(456): Piwik\Console->Piwik{closure}()
#16 /var/www/stat/core/Console.php(80): Piwik\Access::doAsSuperUser(Object(Closure))
#17 /var/www/stat/vendor/symfony/console/Symfony/Component/Console/Application.php(126): Piwik\Console->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/stat/console(27): Symfony\Component\Console\Application->run()
#19 {main}


(Matthieu Aubry) #2

Hi there,

What maxmind DB URL did you set in Administration > Geo location settings?


(kkretsch) #3

The URL is
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
(hope its right, but that worked for weeks/months until now.


#4

Hello,

same error here. Since august once in a month I got this error. I use the same URL.


#5

Was there a fix to this as I have also started getting the error.


(Walter) #6

Hi everyone,

No fixes yet and same issue…

Maybe some issue with code here: (Line 175 of GeoIPAutoUpdater.php)

protected function downloadFile($dbType, $url)
{
    $url = trim($url);
    $ext = GeoIPAutoUpdater::getGeoIPUrlExtension($url);
    // NOTE: using the first item in $dbNames[$dbType] makes sure GeoLiteCity will be renamed to GeoIPCity
    $zippedFilename = GeoIp::$dbNames[$dbType][0] . '.' . $ext;
    $zippedOutputPath = GeoIp::getPathForGeoIpDatabase($zippedFilename);
    $url = self::removeDateFromUrl($url);
    // download zipped file to misc dir
    try {
        $success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath);
    } catch (Exception $ex) {
        throw new Exception("GeoIPAutoUpdater: failed to download '$url' to "
            . "'$zippedOutputPath': " . $ex->getMessage());
    }
    if ($success !== true) {
        throw new Exception("GeoIPAutoUpdater: failed to download '$url' to "
            . "'$zippedOutputPath'! (Unknown error)");
    }
    Log::info("GeoIPAutoUpdater: successfully downloaded '%s'", $url);
    try {
        self::unzipDownloadedFile($zippedOutputPath, $unlink = true);
    } catch (Exception $ex) {
        throw new Exception("GeoIPAutoUpdater: failed to unzip '$zippedOutputPath' after "
            . "downloading " . "'$url': " . $ex->getMessage());
    }
    Log::info("GeoIPAutoUpdater: successfully updated GeoIP database '%s'", $url);
}

(Matthieu Aubry) #7

Thank you for letting us know about this issue! we have created a bug report @ GeoIPAutoUpdater fails with "failed to unzip '/var/www/stat/misc/GeoIPCity.dat.dat.gz' · Issue #9544 · matomo-org/piwik · GitHub and will investigate. Stay tuned on the issue for more info!


(Lukas H) #8

I had a similar issue which was caused by file-permissions. If you do the achieving with cron, your cron script might run a different then your webhost. (e.g. in my case cron was running the script with www-data but the directories belonged to user1, www-data was in user1’s group). In this case make sure that you /misc/ folder is writable for www-data AND the file /misc/GeoIPCity.dat which is getting overwritten.


#9

Not a permission problem here but something else. Issue #9544 was not updated, so I still face the issue.