Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gateway Timeout on core:archive task #14359

Closed
zitrusblau opened this issue Apr 18, 2019 · 11 comments
Closed

Gateway Timeout on core:archive task #14359

zitrusblau opened this issue Apr 18, 2019 · 11 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@zitrusblau
Copy link

Hey,

just wanted to setup the archive cron but running into the following error when triggering it manually:

/path/to/matomo/core/Common.php(271): Notice - unserialize(): Error at offset 0 of 246 bytes - Matomo 3.9.1

Error: Error unserializing the following response from ?module=API&method=API.get&idSite=1&period=week&date=last260&format=php&trigger=archivephp: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>504 Gateway Timeout</title> </head><body> <h1>Gateway Timeout</h1> <p>The gateway did not receive a timely response from the upstream server or application.</p> </body></html>

Wondering what might cause this. Couldn't find a solution to this problem yet.

Raising execution times (180 sec) and memory limits (512MB) didn't help either.

ran this command with
PHP 7.2.3 (cli) (built: Mar 5 2018 11:28:44) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.5, Copyright (c) 2002-2018, by ionCube Ltd.

@fdellwing
Copy link
Contributor

This is pretty much not a bug in Matomo, so the forums would be a better place for this.

Anyway, please take a look into your PHP error log from Matomo to see if there is anything related to the triggered archiving requests.

@zitrusblau
Copy link
Author

Ok, thanks. Added a new forum topic then:
https://forum.matomo.org/t/gateway-timout-issue-on-cron-archive-task/32583

Unfortunately, nothing shows up in the error logfile related to this.

@tsteur tsteur closed this as completed Apr 18, 2019
@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label Apr 18, 2019
@gpanagiotidis
Copy link

@fdellwing

How do we know that this is not a bug in Matomo?

@fdellwing
Copy link
Contributor

Its simple: If this would be a bug with Matomo, much more users would have it. Furthermore, a gateway timeout is a typical problem for a misconfigured PHP instance.

@gpanagiotidis
Copy link

gpanagiotidis commented May 2, 2019

I am having a similar issue.

The warning message is this:

WARNING [2019-05-02 12:38:48] 2017 /opt/matomo/core/Common.php(271): Notice - unserialize(): Error at offset 0 of 91 bytes - Matomo 3.9.1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)

As you can see, the warning message has this unserialize() that appeared after Matomo 3.9.0. Might have nothing to do with this, I just mention it.

After the warning message, the error message is this:

ERROR [2019-05-02 12:38:52] 2017 Empty or invalid response

504 Gateway Time-out

The server didn't respond in time. for website id 19, Time elapsed: 39.120s, skipping

The thing is that this problem is not consistent with all the websites and all the periods. Right now I am trying to reprocess all the logs and this error doesn't appear after every debug but occasionally.

If the problem is a misconfigured PHP instance, then where should I look for the possible causes/solutions? I have just an installation of Software Collections PHP 7.2 by RedHat and the only values altered in php.ini are the memory_limit and max_execution_time which I have increased.

@fdellwing
Copy link
Contributor

The unserialize error will always be shown if the answer from the server is not the expected, so the problem is unrelated.

What webserver are you using? Is there a reverse proxy in place? Do you use PHP-fpm (probably)?

@gpanagiotidis
Copy link

I am using Apache httpd deployed in Openshift. There is a reverse proxy, not configured by me. I don't know if I am using PHP-fpm, I didn't make any changes in PHP besides installing PHP and changing the two variables mentioned.

The installed packages are:

rh-php72-php \
rh-php72-php-curl \
rh-php72-php-gd \
rh-php72-php-cli \
rh-php72-php-mysqlnd \
rh-php72-php-mbstring \
rh-php72-php-xml

@fdellwing
Copy link
Contributor

fdellwing commented May 2, 2019

Ok, that is a setup I cannot directly help you with. But I can say you one thing: Most webservers have a default timeout configured for proxy handling. You can override this setting, for apache see https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxytimeout.

I prefer a timeout one second shorter than your PHP max_execution_time.

For nginx with php-fpm this would look like fastcgi_read_timeout 119 if the max_execution_time ist 120 seconds.

@gpanagiotidis
Copy link

I am not using fpm thought. Could it be the reason I am seeing this error?

@fdellwing
Copy link
Contributor

fdellwing commented May 2, 2019

Could it be the reason I am seeing this error?

Unlikely.

There is a reverse proxy, not configured by me.

All I said is valid for all proxies, php-fpm is just a very good example.

@gpanagiotidis
Copy link

gpanagiotidis commented May 2, 2019

Sometimes I am also getting:

Oops… there was a problem during the request. Maybe the server had a temporary issue, or maybe you requested a report with too much data. Please try again. If this error occurs repeatedly please contact your Matomo administrator for assistance.

In widgets (eg Visits Over Time) if I request reports for a whole year. The websites are not archived because archiving fails in many sites with the discussed error.

Maybe these issues are related but I have no idea what might be wrong in the server configuration. What do you think?

Also, I should mention that the database without any archived table is around 200GB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

4 participants