swoole 处理 has already been bound to another coroutine xxx异常
分享下之前在使用swoole开发项目时遇到的swoole协程问题。swoole 异常信息 P Fatal error: Uncaught Swoole\Error: Socket#37 has already been bound xxxPHP Fatal error: Uncaught Swoole\Error: Socket#37 has already been bound to another coroutine#19895, reading of the same socket in coroutine#19896 at the same time is not allowed in /www/wwwroot/default/vendor/xxx.php:34
Stack trace:
xxxxxxxxxx问题分析 从日志看像是同一个Socket链接不能同时存在于不同的协程里面,也就是不能夸协程使用mysql,redis同一条连接对象。问题处理 知道问题就好处理了可以使用swoole channel 实现一个连接池如下:Channelprivate static ...