GatewayWorker
GatewayWorker copied to clipboard
workerman.log日志经常出现以下错误导致进程退出
topthink/think-worker版本为:v2.0.12 gateway版本为:v3.0.18 异常一: unpack(): Type N: not enough input, need 4, have 1 in /xxx/vendor/workerman/gateway-worker/src/Protocols/GatewayProtocol.php:198 异常二: unserialize(): Error at offset 0 of 136 bytes in /xxx/vendor/workerman/gateway-worker/src/Protocols/GatewayProtocol.php:211
异常一看起来是 手动调用了 GatewayProtocol::decode()方法,传输的数据长度不够,框架流程应该是先调用input判断长度是否足够,足够才会调用decode,从报错看是直接调用了decode。看下你的代码是否有手动调用它,或者改了gatewayWorker源码。 异常二有可能和异常一有关,先定位异常一。 /xxx/vendor/workerman/gateway-worker/src/Protocols/GatewayProtocol.php:198 unpack返回失败时,记录下日志。 利用Excpetion把$buffer和调用栈记录下来,看下哪里调用的decode,记录方法类似
file_put_contents('/tmp/gateway.log', "buffer:$buffer" . (new Excpetion('GatewayProtocol')). "\n"), FILE_APPEND);