workman websocket问题

iqige

经常出现一下这样的错误信息,然后进程正常退出

process_timeout:
#1 /home/project/supereye-websocket/vendor/workerman/gateway-worker/src/Lib/Gateway.php(377): GatewayWorker\Lib\Gateway::sendAndRecv('127.0.0.1:2300', Array)
#2 /home/project/supereye-websocket/Applications/Action/WeChat.php(426): GatewayWorker\Lib\Gateway::isOnline('7f00000108fc000...')
#3 /home/project/supereye-websocket/Applications/Action/WeChat.php(410): WeChat->clearInvalidClient(Array)
#4 /home/project/supereye-websocket/Applications/Chat/Events.php(144): WeChat->onClose('7f00000108fc000...')
#5 : Events::onClose('7f00000108fc000...')
#6 /home/project/supereye-websocket/vendor/workerman/gateway-worker/src/BusinessWorker.php(409): call_user_func('Events::onClose', '7f00000108fc000...')
#7 : GatewayWorker\BusinessWorker->onGatewayMessage(Object(Workerman\Connection\AsyncTcpConnection), Array)
#8 /home/project/supereye-websocket/vendor/workerman/workerman/Connection/TcpConnection.php(658): call_user_func(Array, Object(Workerman\Connection\AsyncTcpConnection), Array)
#9 /home/project/supereye-websocket/vendor/react/event-loop/src/StreamSelectLoop.php(244): Workerman\Connection\TcpConnection->baseRead(Resource id #56)
#10 /home/project/supereye-websocket/vendor/react/event-loop/src/StreamSelectLoop.php(211): React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
#11 /home/project/supereye-websocket/vendor/workerman/workerman/Events/React/Base.php(252): React\EventLoop\StreamSelectLoop->run()
#12 /home/project/supereye-websocket/vendor/workerman/workerman/Events/React/Base.php(135): Workerman\Events\React\Base->run()
#13 /home/project/supereye-websocket/vendor/workerman/workerman/Worker.php(2321): Workerman\Events\React\Base->loop()
#14 /home/project/supereye-websocket/vendor/workerman/gateway-worker/src/BusinessWorker.php(197): Workerman\Worker->run()
#15 /home/project/supereye-websocket/vendor/workerman/workerman/Worker.php(1452): GatewayWorker\BusinessWorker->run()
#16 /home/project/supereye-websocket/vendor/workerman/workerman/Worker.php(1282): Workerman\Worker::forkOneWorkerForLinux(Object(GatewayWorker\BusinessWorker))
#17 /home/project/supereye-websocket/vendor/workerman/workerman/Worker.php(1256): Workerman\Worker::forkWorkersForLinux()
#18 /home/project/supereye-websocket/vendor/workerman/workerman/Worker.php(507): Workerman\Worker::forkWorkers()
#19 /home/project/supereye-websocket/start.php(42): Workerman\Worker::runAll()
#20 {main}

还有,status中的进程没有busy,但是想要连上websocket需要随缘

4628 1 0
1个回答

phpcreeper

这是业务处理超时导致的,当没有设置超时处理函数时或者超时处理函数返回为空时,businessworker进程就会因此退出,从而导致businessworker与gateway的连接中断, 所以从两方面着手:
1、排查业务阻塞的原因;
2、设置处理超时回调以捕捉业务异常,避免进程退出; $businessworker->processTimeoutHandler(String $trace, Exception $exception)

  • iqige 2019-09-16

    根据错误栈的提示,不是应该阻塞在检查客户端是否在线这一步吗,我看了下sendAndRecv这个方法,已经设置了超时。另外,有个问题,如果出现了busy进程,strace -ttp pid 配合php start.php status -d ,追踪是这样子的:
    11:17:54.169967 rt_sigreturn({mask=[]}) = 45
    11:17:54.170040 recvfrom(6, 0x7f8dbea58018, 655350, 0, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
    11:17:55.167907 --- SIGUSR2 {si_signo=SIGUSR2, si_code=SI_USER, si_pid=18243, si_uid=0} ---
    11:17:55.168112 rt_sigreturn({mask=[]}) = 45
    11:17:55.168265 recvfrom(6, 0x7f8dbea58018, 655350, 0, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
    11:17:56.170834 --- SIGUSR2 {si_signo=SIGUSR2, si_code=SI_USER, si_pid=18243, si_uid=0} ---
    11:17:56.170961 rt_sigreturn({mask=[]}) = 45
    11:17:56.171059 recvfrom(6, 0x7f8dbea58018, 655350, 0, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
    11:17:57.171275 --- SIGUSR2 {si_signo=SIGUSR2, si_code=SI_USER, si_pid=18243, si_uid=0} ---
    11:17:57.171352 rt_sigreturn({mask=[]}) = 45
    猜测,是不是就是卡在检查是否在线这一步?

  • phpcreeper 2019-09-16

    这里的业务处理超时是针对 Events 的四个 onXXXX回调里的整体业务存在阻塞时而言的,这和sendAndRecv() 这个tcp连接的超时完全不是一回事, 反过来,根据题示栈信息也可以看出这个方法也是在onClose 回调触发的,不管怎样,这也只是相当于整体业务里的一个局部子单元业务。

  • iqige 2019-09-17

    原来如此

年代过于久远,无法发表回答
×
🔝