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,
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; }
3. Delete or comment out the isBreak function in /library/think/db/connector/Mysql.php.
After modification, workerman will 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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools