"Got an error reading communication packets"

Hello,

I have a fresh installation of Matomo 4.11.0 running on a Apache2 server with PHP 7.4 FPM behind a reverseproxy.
I was able to add a website and see real time events but opening most of the pages of Matomo (for example Visitors > Overview) gives me the following error: (Translated with Google from German to English)

Oops… there was a problem during the request. The server may have been temporarily overloaded, or you may have requested a report with too much data. Please try again.

PHP log:
[Tue Aug 30 12:42:35.720154 2022] [proxy_fcgi:error] [pid 3193125] [client 10.254.9.4:39936] AH01071: Got error 'PHP message: [analytics] Error in Matomo: Mysqli prepare error: MySQL server has gone awayPHP message: PHP Fatal error: Uncaught Zend_Db_Statement_Mysqli_Exception: Mysqli prepare error: MySQL server has gone away in /var/www/analytics/libs/Zend/Db/Statement/Mysqli.php:77\nStack trace:\n#0 /var/www/analytics/libs/Zend/Db/Statement.php(115): Zend_Db_Statement_Mysqli->_prepare()\n#1 /var/www/analytics/libs/Zend/Db/Adapter/Mysqli.php(423): Zend_Db_Statement->__construct()\n#2 /var/www/analytics/libs/Zend/Db/Adapter/Abstract.php(478): Zend_Db_Adapter_Mysqli->prepare()\n#3 /var/www/analytics/core/Session/SaveHandler/DbTable.php(124): Zend_Db_Adapter_Abstract->query()\n#4 /var/www/analytics/core/Session/SaveHandler/DbTable.php(158): Piwik\\Session\\SaveHandler\\DbTable->query()\n#5 [internal function]: Piwik\\Session\\SaveHandler\\DbTable->write()\n#6 /var/www/analytics/libs/Zend/Session.php(731): session_write_close()\n#7 [internal function]: Zend_Session::writeClose()\n#8 {main}\n thrown in /var/www/analytics/...', referer: https://analytics/index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday

MariaDB log:
2022-08-30 12:42:21 906 [Warning] Aborted connection 906 to db: 'matomo_analytics' user: 'matomo' host: '10.254.9.5' (Got an error reading communication packets)

MariaDB config (relevant settings only):

max_allowed_packet     = 1G
max_connections        = 500
interactive_timeout     = 6000
innodb_log_buffer_size = 1G
innodb_log_file_size = 4G
wait_timeout          = 28800

These values are currently set very high for testing. The values from the FAQ entry also didn’t help.

When I enable the mysql general log , i can see that matomo is sending queries to the sql server but there don’t seem to be any errors or anything that indicates that somethings wrong.

PHP modules are all up and running:

apc, apcu, bcmath, calendar, Core, ctype, curl, date, dom, exif, FFI, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imagick, intl, json, libxml, mbstring, mcrypt, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, posix, readline, Reflection, session, shmop, SimpleXML, sockets, sodium, SPL, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlreader, xmlwriter, xsl, Zend OPcache, zip, zlib

I tried using the PDO\MYSQL and the MYSQLI adapter, but that changed nothing.

What should i do now?

Thank you.

Did you try to simply connect the database from the Matomo server, running the SQL client from the Apache user and using the Matomo database user, just to check the connection is OK?

Not yet, no, but i have about 30 other websites running on the same host and none of them have any issues with the database connection. Will test this though just to be sure.

Maybe to much connections at the same time on the database from the same IP?

I checked , there are never more than 2 or 3 queries running at the same time

But i found this.

                   477 Query    LOAD DATA INFILE
                                '/var/www/analytics/tmp/assets/matomo_archive_blob_2022_08-8219f7dd7140235fa70a89e2895555a6.csv'
                        REPLACE
                        INTO TABLE
                                `matomo_archive_blob_2022_08` CHARACTER SET latin1
                        FIELDS TERMINATED BY
                                '       '
                        ENCLOSED BY
                                '"'
                 ESCAPED BY '\\'
                        LINES TERMINATED BY
                                '
'
                        (idarchive,idsite,date1,date2,period,ts_archived,name,value)
                   477 Query    LOAD DATA LOCAL INFILE
                                '/var/www/analytics/tmp/assets/matomo_archive_blob_2022_08-8219f7dd7140235fa70a89e2895555a6.csv'
                        REPLACE
                        INTO TABLE
                                `matomo_archive_blob_2022_08` CHARACTER SET latin1
                        FIELDS TERMINATED BY
                                '       '
                        ENCLOSED BY
                                '"'
                 ESCAPED BY '\\'
                        LINES TERMINATED BY
                                '
'
                        (idarchive,idsite,date1,date2,period,ts_archived,name,value)

Matomo runs this SQL query but doesn’t seem to finish or quit. The “load data infile” feature is enabled in my sql server but the queries from Matomo stop here until i reload a page.

Is this expected behavior?

Yeah, I’m definitely on to someting:

INFO [2022-08-31 12:58:57] 3406095  LOAD DATA INFILE failed... Error was:
  Try #1: LOAD DATA LOCAL INFILE : SQLSTATE[HY000]: General error: 2027 Malformed packet,
  Try #2: LOAD DATA LOCAL INFILE : SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

Just need to figure out why this is happening.

1 Like

I switched from MariaDB to MySQL and it all works now. I was not able to find out what the exact reson is for this issue.

1 Like