Response was 'curl_exec: Empty reply from server' since upgrade to 2.0.1/2

HI all,

I’m getting the following reply when doing a daily archive


ERROR: Got invalid response from API request: https://example.com/index.php?module=API&method=VisitsSummary.getVisits&idSite=4&period=day&date=last52&format=php&token_auth=xxxx&trigger=archivephp. Response was 'curl_exec: Empty reply from server'

I only archive data on this server daily because it does a import via the log analytics tool, then I run a archive straight away. Is this because Piwik is taking to long to response, IE it’s still doing something? Or some other reason?

Is it possible to set the timeout on the archive script a bit higher to see if that helps? I can’t see any errors in my apache logs or anything, so I assume it’s just because it’s taking longer than the archive script wants.

Any error in the “error.log” ?

Nah nothing in the /tmp/logs directory in Piwik nor the apache error log, I guess it’s just taking a really long time making the archive script think it’s erroring, it takes a few time but it eventually manages to run without issue.

The same error occurs in my piwik 2.0.3 installation. The archive script is started by a cron job each night. I played around to start the script at unbusy times. There is always this error message in the morning, send by an email. I can start the script manually and it runs without problems.

Has anyone an idea?

I think it happens when piwik takes to long to reply to the archive script, I’ve found that it only happens on two of my websites, both gets lots of traffic and only happens on really busy days.

Thank you for your answer. Did you try to change max_execution_time in php.ini ? I will test it and let you know.

I’ve checked it’s not my max_execution_time since it’s the cron saying it didn’t get a reply and my error log for apache isn’t saying it’s got a php timeout

and did you try to increase default_socket_timeout and/or curlopt_timeout too?

I have the same problem as this followin the upgrade.

[quote=mucctecc]
and did you try to increase default_socket_timeout and/or curlopt_timeout too?[/quote]

How do you do this ? I am trying to run it from CRON every 5 mins.

I just know to set default_socket_timeout in the php.ini. Unfortunately, I do not know the place in piwik where to give curlopt_timeout a new value, WITHOUT going in the source code - thats why I askes here :slight_smile:

There really should be some error in the server error.log if configured properly?

There are no specific errors in the php error log file;

/etc/php.ini:
error_reporting = E_ALL
error_log = /srv/www/logs/php_error.log
log_errors = On

grep curl php_error.log and grep archive php_error.log returns no results.

archive.php is called via
0 3 * * * /usr/local/bin/php /srv/www/htdocs/piwik/misc/cron/archive.php --url=http://xxx.de > /home/piwik/logs/piwik-archive.log

piwik-archive.log contains:
INFO [2014-02-03 02:00:31] [3ccfc] ERROR: Got invalid response from API request: https://xxx.de/index.php?module=API&method=VisitsSummary.getVisits&idSite=2&period=day&date=last52&format=php&token_auth=yyy&trigger=archivephp. Response was 'curl_exec: Empty reply from server’
INFO [2014-02-03 02:01:35] [3ccfc] Total daily visits archived: 146

This is the known error …

Thank you for your help!