Cron Job: Got invalid response from API request


(Carlos) #1

Hello,

I have a problem, that I already have found that some people had the same problem. However the solutions that solved didn’t work to me.
I have Matomo (piwik) working for 2 years. A few months ago (3 or 4) I had a second web site to it. About a 1,5 months ago I start to have the following an error on the Cron Job.

The problem is the cron job that is executed every hour. I start to get the following error:

ERROR [2018-05-02 14:13:02] Got invalid response from API request: ?module=API&method=API.get&idSite=1&period=day&date=last52&format=php&trigger=archivephp. The response was empty. This usually means a server error. A solution to this error is generally to increase the value of ‘memory_limit’ in your php.ini file. For more information and the error message please check in your PHP CLI error log file. As this core:archive command triggers PHP processes over the CLI, you can find where PHP CLI logs are stored by running this command: php -i | grep error_log
ERROR [2018-05-02 14:13:02] Empty or invalid response ‘’ for website id 1, Time elapsed: 0.530s, skipping
ERROR [2018-05-02 14:13:03] Got invalid response from API request: ?module=API&method=API.get&idSite=2&period=day&date=last52&format=php&trigger=archivephp. The response was empty. This usually means a server error. A solution to this error is generally to increase the value of ‘memory_limit’ in your php.ini file. For more information and the error message please check in your PHP CLI error log file. As this core:archive command triggers PHP processes over the CLI, you can find where PHP CLI logs are stored by running this command: php -i | grep error_log
ERROR [2018-05-02 14:13:03] Empty or invalid response ‘’ for website id 2, Time elapsed: 0.664s, skipping
ERROR [2018-05-02 14:13:03] 4 total errors during this script execution, please investigate and try and fix these errors.

I don’t have direct access to the server, all the access is made by Cpanel.
the cron execution is:
/opt/alt/php56/usr/bin/php /home/MYFOLDER/public_html/WEBSITEFOLDER/piwik/console core:archive --url=http://MYDOMAIN/piwik/ > /dev/null

Server information:
Apache Version 2.4.25
PHP Version 5.6.30
MySQL Version 10.1.32-MariaDB
Matomo 3.4.0

I have heck the memory size, and was increased to 512Mb
I have add to the command line --accept-invalid-ssl-certificate
The 2 web site together have less that 70 visits a day.

Meanwhile I have found that on Matomo Settings:
System -> General Settings
under the option “Archiving settings”, was Yes by default and "Archive reports at most every 150 seconds"
I just disable it, and make some visits to the both web sites and force to execute the cron job, and still have the same error.

Any idea? I thanks any help that can give me.


(Lukas Winkler) #3

Hi,

As an PHP error occurs, the only place to get an answer on the cause is the PHP error_log. It should show you why the requests fail.


(Carlos) #4

Hi Lucas,

Thanks for your reply.
I the error_log file inside the folder where Matomo is installed?
If so, I only have this:
[21-Sep-2017 08:38:28 UTC] Error in Piwik: Your Piwik version 3.1.1 is up to date.
[13-Oct-2017 17:28:15 UTC] Error in Piwik: Your Piwik version 3.2.0 is up to date.
[17-Oct-2017 11:30:05 UTC] Error in Piwik: Mysqli statement execute error : Prepared statement needs to be re-prepared
[10-Mar-2018 03:15:33 UTC] Error in Matomo (tracker): Invalid idSite: ‘0’
[21-Mar-2018 08:59:43 UTC] Error in Matomo: You are logged in as ‘daniel.santos’ but it seems you don’t have any permission set in Matomo. Ask your Matomo administrator (click to email) to give you ‘view’ access to a website.   › Sair
[28-Mar-2018 07:13:04 UTC] Error in Matomo (tracker): Invalid idSite: ‘0’
[17-Apr-2018 09:27:37 UTC] Error in Matomo (tracker): Invalid idSite: ‘0’
[17-Apr-2018 09:30:40 UTC] Error in Matomo (tracker): Invalid idSite: ‘0’
[17-Apr-2018 09:31:07 UTC] Error in Matomo (tracker): Invalid idSite: ‘0’
[17-Apr-2018 09:31:14 UTC] Error in Matomo (tracker): Invalid idSite: ‘0’
[27-Apr-2018 10:53:03 UTC] Error in Matomo (tracker): Invalid idSite: ‘0’


(Lukas Winkler) #5

Hi,

I don’t think this is what causes the issue.

The location of the error_log depends on your PHP config. If you don’t have access to the server, you may have a log folder in your ftp or have to ask your host.


(Fabian Dellwing) #6

This error sometimes just happens for me too, but I just ignore it. We run the script every 15 Minutes and it does not matter if this failes one or two times. So just to be sure: Your problem persists and is there every time the cron gets executed?


(Carlos) #7

Hi Lucas,

Thanks for the reply.
I have check with the host, and on each folder that the error occurs will generate the error_log.
The previews information send, is the error_log from the folder where is the console file.


(Carlos) #8

Hi Fabian,

Thanks for the reply.
Is every time that the cron is executed. In my case every hour.