How to solve the error problem of workerman+tp5

藏色散人
Release: 2021-02-01 12:06:20
Original
3139 people have browsed it

How to solve the error problem of workerman+tp5

How to solve the error problem of workerman tp5? thinkphp5 workererman error reporting problem

In the early version of thinkphp5.0. The reason is that the database is disconnected due to long-term connection to the database.

Recommended: "Workerman Tutorial"

Solution:

1. Modify the database Configure the database.php file and set the break_reconnect parameter to true. Disconnect and reconnect.

// 是否需要断线重连 'break_reconnect' => true,
Copy after login

2. Modify the isBreak function in /library/think/db/Connection.php and replace it with the latest isBreak function below.

/** * 是否断线 * @access protected * @param \PDOException|\Exception $e 异常对象 * @return bool */ protected function isBreak($e) { if (!$this->config['break_reconnect']) { return false; } $info = [ 'server has gone away', 'no connection to the server', 'Lost connection', 'is dead or not enabled', 'Error while sending', 'decryption failed or bad record mac', 'server closed the connection unexpectedly', 'SSL connection has been closed unexpectedly', 'Error writing data to the connection', 'Resource deadlock avoided', 'failed with errno', ]; $error = $e->getMessage(); foreach ($info as $msg) { if (false !== stripos($error, $msg)) { return true; } } return false; }
Copy after login

3. Delete or comment out the isBreak function in /library/think/db/connector/Mysql.php.

After modification,workermanwill be connected to the database for a long time. If the database is disconnected, it will be reconnected.

The above is the detailed content of How to solve the error problem of workerman+tp5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!