Archive.php: Got invalid response from API request (The response was empty)

Well just updated to the latest Beta release, 2.2.0-b18, and that seemed to have done the trick.
Ran the script again and no errors so far…


INFO CoreConsole[2014-04-09 20:22:33] [a2fcb] ---------------------------
INFO CoreConsole[2014-04-09 20:22:33] [a2fcb] INIT
INFO CoreConsole[2014-04-09 20:22:33] [a2fcb] Piwik is installed at: http://[domain]/piwik/index.php
INFO CoreConsole[2014-04-09 20:22:33] [a2fcb] Running Piwik 2.2.0-b18 as Super User: admin
INFO CoreConsole[2014-04-09 20:22:44] [a2fcb] ---------------------------
INFO CoreConsole[2014-04-09 20:22:44] [a2fcb] NOTES
INFO CoreConsole[2014-04-09 20:22:44] [a2fcb] - If you execute this script at least once per hour (or more often) in a crontab, you may disable 'Browser trigger archiving' in Piwik UI > Settings > General Settings. 
INFO CoreConsole[2014-04-09 20:22:44] [a2fcb]   See the doc at: http://piwik.org/docs/setup-auto-archiving/
INFO CoreConsole[2014-04-09 20:22:44] [a2fcb] - Reports for today will be processed at most every 10 seconds. You can change this value in Piwik UI > Settings > General Settings.
INFO CoreConsole[2014-04-09 20:22:44] [a2fcb] - Reports for the current week/month/year will be refreshed at most every 3600 seconds.
INFO CoreConsole[2014-04-09 20:22:44] [a2fcb] - Archiving was last executed without error 21 days 3 hours ago
INFO CoreConsole[2014-04-09 20:22:45] [a2fcb] - Will process 2 websites with new visits since 21 days 3 hours , IDs: 2, 3
INFO CoreConsole[2014-04-09 20:22:45] [a2fcb] - Will process 2 other websites because some old data reports have been invalidated (eg. using the Log Import script) , IDs: 3, 2
INFO CoreConsole[2014-04-09 18:22:45] [a2fcb] ---------------------------
INFO CoreConsole[2014-04-09 18:22:45] [a2fcb] START
INFO CoreConsole[2014-04-09 18:22:45] [a2fcb] Starting Piwik reports archiving...
INFO CoreConsole[2014-04-09 18:22:58] [a2fcb] Archived website id = 2, period = day, 2255 visits in last 52 days, 1 visits today, Time elapsed: 13.178s

INFO CoreConsole[2014-04-09 18:24:44] [a2fcb] Archived website id = 2, period = week, 6155 visits in last 23 weeks, 42 visits this week, Time elapsed: 105.996s
INFO CoreConsole[2014-04-09 18:25:19] [a2fcb] Archived website id = 2, period = month, 6986 visits in last 23 months, 355 visits this month, Time elapsed: 35.159s
INFO CoreConsole[2014-04-09 18:25:43] [a2fcb] Archived website id = 2, period = year, 6986 visits in last 7 years, 4091 visits this year, Time elapsed: 23.709s
INFO CoreConsole[2014-04-09 18:25:43] [a2fcb] Archived website id = 2, 4 API requests, Time elapsed: 178.105s [1/2 done]
INFO CoreConsole[2014-04-09 18:26:52] [a2fcb] Archived website id = 3, period = day, 2256 visits in last 52 days, 1 visits today, Time elapsed: 69.156s
INFO CoreConsole[2014-04-09 18:28:38] [a2fcb] Archived website id = 3, period = week, 6147 visits in last 23 weeks, 42 visits this week, Time elapsed: 106.241s
INFO CoreConsole[2014-04-09 18:29:08] [a2fcb] Archived website id = 3, period = month, 6978 visits in last 23 months, 355 visits this month, Time elapsed: 29.202s
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Archived website id = 3, period = year, 6978 visits in last 7 years, 4089 visits this year, Time elapsed: 26.367s
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Archived website id = 3, 4 API requests, Time elapsed: 231.127s [2/2 done]
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Done archiving!
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] ---------------------------
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] SUMMARY
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Total visits for today across archived websites: 2
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Archived today's reports for 2 websites
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Archived week/month/year for 2 websites
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Skipped 0 websites: no new visit since the last script execution
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Skipped 0 websites day archiving: existing daily reports are less than 10 seconds old
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Skipped 0 websites week/month/year archiving: existing periods reports are less than 3600 seconds old
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Total API requests: 8
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] done: 2/2 100%, 2 vtoday, 2 wtoday, 2 wperiods, 8 req, 409292 ms, no error
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Time elapsed: 409.293s
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] ---------------------------
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] SCHEDULED TASKS
INFO CoreConsole[2014-04-09 18:29:34] [a2fcb] Starting Scheduled tasks... 
task,output
CoreAdminHome.purgeOutdatedArchives,Time elapsed: 0.430s
PrivacyManager.deleteReportData,Time elapsed: 0.041s
PrivacyManager.deleteLogData,Time elapsed: 0.002s
Piwik\Plugins\CorePluginsAdmin\MarketplaceApiClient.clearAllCacheEntries,Time elapsed: 0.114s
CoreAdminHome.optimizeArchiveTable,Time elapsed: 0.822s
INFO CoreConsole[2014-04-09 18:29:43] [a2fcb] done
INFO CoreConsole[2014-04-09 18:29:43] [a2fcb] ---------------------------
DiskStation> 

Well just updated to the latest Beta release, 2.2.0-b18, and that seemed to have done the trick.

I have everything still. Apparently, the user rights trickster.
When direct request addresses causing error does get through the serialized string.

I’ve updated to 2.2.0-b18 but am still getting the same error as before.

I’ve also tried to run the archive task using the recommended new way like so:


php D:\apache-piwik\vhosts\tst-piwik.{mydomain}\www/console core:archive --url=http://tst-piwik.{mydomain}/

Still the same error output - and still no entries in the server log as to why the supposedly empty response:


INFO CoreConsole[2014-04-10 12:11:39] [dde6d] ---------------------------
INFO CoreConsole[2014-04-10 12:11:39] [dde6d] INIT
INFO CoreConsole[2014-04-10 12:11:39] [dde6d] Piwik is installed at: http://tst-piwik.{mydomain}/index.php
INFO CoreConsole[2014-04-10 12:11:39] [dde6d] Running Piwik 2.2.0-b18 as Super User: piwik_su
INFO CoreConsole[2014-04-10 12:11:41] [dde6d] ERROR: Got invalid response from API request: http://tst-piwik.{mydomain}/index.php?module=API&method=API.getDefaultMetricTranslations&format=original&serialize=1&trigger=archivephp. Response
was 'Got invalid response from API request: http://tst-piwik.{mydomain}/index.php?module=API&method=API.getDefaultMetr
icTranslations&format=original&serialize=1&trigger=archivephp. The response was empty. This usually means a server error
. This solution to this error is generally to increase the value of 'memory_limit' in your php.ini file. Please check yo
ur Web server Error Log file for more details.'
INFO CoreConsole[2014-04-10 12:11:41] [dde6d] ERROR: The Piwik URL http://tst-piwik.{mydomain}/index.php does not seem
 to be pointing to a Piwik server. Response was ''.
Error in the last Piwik archive.php run:
The Piwik URL http://tst-piwik.{mydomain}/index.php does not seem to be pointing to a Piwik server. Response was ''.

Same problem here too.

Steps to the error:

  • Installed Piwik 2.1.0 some time ago on (PHP 5.3/ubuntu, later PHP 5.4) on own dedicated root. Cronjob (Calling archive.php with token_outh in a cronjob), Tracking (about 2000 Unique Users per day) and all worked fine until a few days ago.
  • Than the error “Got invalid response from API request…index.php?module=API&method=API.getDefaultMetricTra…” appeared and the cronjob or manual call of the archive.php doesn’t worked anymore. Calling the “index.php?module=API&method=API.getDefaultMetricTra…” manually works fine and shows some serialized data (seems like json), no errors logged.
  • Tried to update to newest beta “2.2.0-b18” - Same problem, not fixed. Everything else working fine.
  • If i enable browser triggered archive than this do the job fine also.
  • At last fixed it with using the new cronjob method: “php /srv/piwik.path/console core:archive --url=https://piwikurl”
  • The https certificate is self-signed.

What i’ve done few days ago, what can cause this problems, is a PHP update from 5.3.x to 5.4.27 - I don’t know if this is the reason for my probs, just for the info.

For me it’s fixed with using the new cronjob method, but old method with calling archive.php still don’t work and list the error “Got invalid response from API request”.

I must revise my previous post.
It’s also NOT fixed for me.

The cronjob now runs without errors but it always says “Skipped 3 websites: no new visit since the last script execution”.
If i enable browser update, it does a correct update of reports, but not with the cronjob itself.

I don’t have any idea to fix this, as my previous poster.

I’m experiencing the same issue with Piwik 2.1.0. My environment:

  • Windows Server 2008 R2 Standard
  • IIS 7.5
  • PHP 5.5.10

Updated to 2.2.0-rc2 today and still the same “response was empty” error as above when trying to run the archive.php.


Got invalid response from API request:
https://tst-piwik.mydomain/index.php?module=API&method=API.getDefaultMetricTranslations&format=original&serialize=1&trigger=archivephp. The response was empty

The response however does not appear to be empty at all:


a:40:{s:9:"nb_visits";s:6:"Visits";s:16:"nb_uniq_visitors";s:15:"Unique visitors";s:10:"nb_actions";s:7:"Actions";s:20:"nb_actions_per_visit";s:17:"Actions per Visit";s:16:"avg_time_on_site";s:20:"Avg. Time on Website";s:11:"bounce_rate";s:11:"Bounce Rate";s:15:"conversion_rate";s:15:"Conversion Rate";s:5:"label";s:5:"Label";s:4:"date";s:4:"Date";s:16:"avg_time_on_page";s:17:"Avg. time on page";s:14:"sum_time_spent";s:41:"Total time spent by visitors (in seconds)";s:16:"sum_visit_length";s:41:"Total time spent by visitors (in seconds)";s:12:"bounce_count";s:7:"Bounces";s:22:"bounce_count_returning";s:33:"Bounce Count for Returning Visits";s:11:"max_actions";s:28:"Maximum actions in one visit";s:21:"max_actions_returning";s:38:"Maximum actions in one returning visit";s:29:"nb_visits_converted_returning";s:36:"Number of converted returning visits";s:26:"sum_visit_length_returning";s:51:"Total time spent by returning visitors (in seconds)";s:19:"nb_visits_converted";s:23:"Visits with Conversions";s:14:"nb_conversions";s:11:"Conversions";s:7:"revenue";s:7:"Revenue";s:7:"nb_hits";s:9:"Pageviews";s:15:"entry_nb_visits";s:9:"Entrances";s:22:"entry_nb_uniq_visitors";s:16:"Unique entrances";s:14:"exit_nb_visits";s:5:"Exits";s:21:"exit_nb_uniq_visitors";s:12:"Unique exits";s:18:"entry_bounce_count";s:7:"Bounces";s:17:"exit_bounce_count";s:7:"Bounces";s:9:"exit_rate";s:9:"Exit rate";s:26:"sum_daily_nb_uniq_visitors";s:27:"Unique visitors (daily sum)";s:32:"sum_daily_entry_nb_uniq_visitors";s:28:"Unique entrances (daily sum)";s:31:"sum_daily_exit_nb_uniq_visitors";s:24:"Unique exits (daily sum)";s:16:"entry_nb_actions";s:27:"Actions after entering here";s:22:"entry_sum_visit_length";s:61:"Total time spent by visitors (in seconds) after entering here";s:9:"nb_events";s:12:"Total events";s:15:"sum_event_value";s:11:"Total value";s:15:"min_event_value";s:13:"Minimum value";s:15:"max_event_value";s:13:"Maximum value";s:15:"avg_event_value";s:13:"Average value";s:20:"nb_events_with_value";s:19:"Events with a value";}

when you get the error “Server response was empty” can you please check your Server error log files? Maybe there is an error listed there?

My error logs are all empty, expect that log from piwik.log itself.
No memory_limit error, no timeout, no other php error, etc…

As ‘Marius’ said, the response is not empty when you call the URL, that he mentioned, manually. Just the cronjob cannot call it.

I GUESS that it have something todo with self signed certs.
Are SSL cert checks disabled? It’s required for self signed certs.

I am running a valid SSL certificate with a chain root ending in a GlobalSign’s root certificate…

I also use a valid certificate of StartCom Ltd.
Backup problem on cron watch even on the latest version 2.2.0-rc3.

I GUESS that it have something todo with self signed certs.
Are SSL cert checks disabled? It’s required for self signed certs.

Did you set the parameter --accept-invalid-ssl-certificate
to the ./console core:archive --url=xx call?

Hi,

same problem for me. After updating from 2.1 to 2.2 the cronjob fails. Settings the --accept-invalid-ssl-certificate does not make a change, neither using the new command line syntax with the console script.

I remeber we had a similar error when going to 2.1 (beta); I think is was an issue with IPv4 and IPv6 resolution of the domain names. In the CLI archiver there was a problem that caused this - but it was fixed in 2.1 as far as I remember…

Any ideas?

When it fails do you see any error in the error file?

There are currently two tickets about Archive cron failing for some particular server configurations: Error when running cron:archive: Response was 'Console ToolUsage: [options] command.... · Issue #5007 · matomo-org/matomo · GitHub and Install with errors, not tracking · Issue #5005 · matomo-org/matomo · GitHub

Finally figured out the real problem.
It’s a weird timezone problem.
I have no “correct” fix yet, but following should make clear that it’s a timezone problem.

  1. First i’ve forgotten --accept-invalid-ssl-certificate, set it in the cronjob. (new with console)
    Failure: Skips all websites, doesn’t matter if it has visits or not

  2. Tested and debugged a lot. Broken down the code and turns out that ALL requests that happens in CLI have another timezone than the in the DB.
    For debug i’ve just added


date_default_timezone_set("UTC");

to the “console” script. And BAM, it works.
For me the DB timestamp is UTC but all timestamps in CLI mode uses the local time (MET) in all functions, especially checked it in “APISitesManager::getInstance()->getSitesIdWithVisits”.

I don’t understand the extremely complicated “Date” Class code.
A cleanup here will make things a lot easier.

Ah and PS: I guess it’s not working with calling the “archive.php” in the browser, if you have https with self signed certs, because you CANNOT set --accept-invalid-ssl-certificate in the URL, this works only for CLI mode.

I found that too. The timestamps in the old archive.php where always UTC (I´m in MESZ) = off 2 hours. This was in 2.0.1. Over to 2.0.2 and the new core:archive procedure.
Had always “Total visits for today across archived websites: 0” - mean did not do any archiving at all. The funny thing - timestamps for INIT and NOTES are in MESZ now - but then START SUMMARY SCHEDULED TASK got UTC´s again (and of course lots of invalid response from API blabla).

My workaround: Add --force-idsites=… and all timestames change to MESZ and no more API blabla in the cron log.

–force-all-websites - Works also for me. But i actually added the “date_default_timezone_set(“UTC”);” to the console script, than updates work as expected.

I tip for the devs: NEVER convert unix timestamp to another timezone. Unix timestamp is per defination always UTC and date(), strtotime() and all other functions expect a UTC Unix Timestamp. I saw that this is not always the case in Piwik - Piwik transform timestamps to another timezone.

I have the same problem with the only site where I have installed Piwik that has a time zone inside Piwik other than the time zone of the server where Piwik is installed.

Is there any update on the issue?

Is there something that I can tweak inside the files to try to resolve the issue?

All input on the matter is much appreciated!