gatewayworker数据库链接地址变动,导致报错64000

dou号

问题描述

events里面的数据库链接之前一直用的外部链接,昨晚改成内部链接并重启gateway后,刚刚重启的片刻,bussinessworker都起来了,设备也能正常收发指令,但是马上就又都掉下去了,把数据库再改回外链也不行,一直报这个错,提高gateway和bussiness的数量,也没用,这个问题持续了两个小时左右,那个时候系统里面应该有不少设备断电了,然后gatewayworker才恢复正常

报错信息

#12 {main}
2024-07-11 23:42:33 pid:20145 WORKER EXIT UNEXPECTED 
2024-07-11 23:42:33 pid:20134 worker[YourAppBusinessWorker:20145] exit with status 64000
2024-07-11 23:42:33 pid:20143 Exception: can not connect to tcp://***.*.*.*:*** Connection refused in /home/GatewayWorker/vendor/workerman/gateway-worker/src/Lib/Gateway.php:725
Stack trace:
#0 /home/GatewayWorker/vendor/workerman/gateway-worker/src/Lib/Gateway.php(674): GatewayWorker\Lib\Gateway::sendAndRecv('***.*.*.*:***', Array)
#1 /home/GatewayWorker/vendor/workerman/gateway-worker/src/BusinessWorker.php(359): GatewayWorker\Lib\Gateway::getSession('7f0000010b55000...')
#2 [internal function]: GatewayWorker\BusinessWorker->onGatewayMessage(Object(Workerman\Connection\AsyncTcpConnection), Array)
#3 /home/GatewayWorker/vendor/workerman/workerman/Connection/TcpConnection.php(480): call_user_func(Array, Object(Workerman\Connection\AsyncTcpConnection), Array)
#4 [internal function]: Workerman\Connection\TcpConnection->baseRead(Resource id #42, 2, Resource id #42)
#5 /home/GatewayWorker/vendor/workerman/workerman/Events/Event.php(185): EventBase->loop()
#6 /home/GatewayWorker/vendor/workerman/workerman/Worker.php(1569): Workerman\Events\Event->loop()
#7 /home/GatewayWorker/vendor/workerman/gateway-worker/src/BusinessWorker.php(190): Workerman\Worker->run()
#8 /home/GatewayWorker/vendor/workerman/workerman/Worker.php(959): GatewayWorker\BusinessWorker->run()
#9 /home/GatewayWorker/vendor/workerman/workerman/Worker.php(922): Workerman\Worker::forkOneWorker(Object(GatewayWorker\BusinessWorker))
#10 /home/GatewayWorker/vendor/workerman/workerman/Worker.php(430): Workerman\Worker::forkWorkers()
#11 /home/GatewayWorker/start.php(38): Workerman\Worker::runAll()
269 1 0
1个回答

walkor 打赏

猜测是因为业务使用了过时的client_id导致的。
client_id里包含了内部通讯端口,如果你落地存储里存储了client_id,当更改了内部端口或者内网通讯地址,使用旧的client_id会导致通讯地址或端口错误。

client_id是临时id,不建议进行落地存储。推荐做法是将client_id与设备绑定(Gateway::bindUid())接口,或者利用分组将设备分组(Gateway::joinGroup())。后续通过设备id或者分组通讯。

如果非要存储$client_id到落地存储,应该在GatewayWorker重启前将落地存储里的$client_id清除,至少也应该在Gateway变更内部端口的时候清理落地存储里的$client_id

  • 暂无评论
×
🔝