在 webman 中使用 gateway-worker 偶尔会出现 Exception: businessWorker::getAllGatewayAddresses return empty in /home/wwwroot/webman/vendor/workerman/gateway-worker/src/Lib/Gateway.php:746
异常
2023-11-16 15:23:45 pid:3611028 Exception: businessWorker::getAllGatewayAddresses return empty in /home/wwwroot/webman/vendor/workerman/gateway-worker/src/Lib/Gateway.php:746
Stack trace:
#0 /home/wwwroot/webman/vendor/workerman/gateway-worker/src/Lib/Gateway.php(724): GatewayWorker\Lib\Gateway::getAllGatewayAddress()
#1 /home/wwwroot/webman/vendor/workerman/gateway-worker/src/Lib/Gateway.php(406): GatewayWorker\Lib\Gateway::getBufferFromAllGateway()
#2 /home/wwwroot/webman/vendor/workerman/gateway-worker/src/Lib/Gateway.php(182): GatewayWorker\Lib\Gateway::getClientIdByUid()
#3 /home/wwwroot/webman/plugin/webman/gateway/Events.php(202): GatewayWorker\Lib\Gateway::isUidOnline()
#4 [internal function]: plugin\webman\gateway\Events::onMessage()
#5 /home/wwwroot/webman/vendor/workerman/gateway-worker/src/BusinessWorker.php(385): call_user_func()
#6 /home/wwwroot/webman/vendor/workerman/workerman/Connection/TcpConnection.php(646): GatewayWorker\BusinessWorker->onGatewayMessage()
#7 /home/wwwroot/webman/vendor/workerman/workerman/Events/Select.php(311): Workerman\Connection\TcpConnection->baseRead()
#8 /home/wwwroot/webman/vendor/workerman/workerman/Worker.php(1629): Workerman\Events\Select->loop()
#9 /home/wwwroot/webman/vendor/workerman/workerman/Worker.php(1423): Workerman\Worker::forkOneWorkerForLinux()
#10 /home/wwwroot/webman/vendor/workerman/workerman/Worker.php(1397): Workerman\Worker::forkWorkersForLinux()
#11 /home/wwwroot/webman/vendor/workerman/workerman/Worker.php(1779): Workerman\Worker::forkWorkers()
#12 /home/wwwroot/webman/vendor/workerman/workerman/Worker.php(1715): Workerman\Worker::monitorWorkersForLinux()
#13 /home/wwwroot/webman/vendor/workerman/workerman/Worker.php(562): Workerman\Worker::monitorWorkers()
#14 /home/wwwroot/webman/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#15 /home/wwwroot/webman/start.php(4): support\App::run()
#16 {main}
2023-11-16 15:23:46 pid:3294652 worker[plugin.webman.gateway-worker.worker:3611028] exit with status 64000
2023-11-16 15:23:53 pid:3294652 Workerman[start.php] reloading
版本信息
"require": {
"workerman/webman-framework": "^1.5.0",
"webman/admin": "^0.6.4",
"webman/gateway-worker": "^1.0",
...
}
gateway-worker 配置信息
<?php
use Webman\GatewayWorker\Gateway;
use Webman\GatewayWorker\BusinessWorker;
use Webman\GatewayWorker\Register;
return [
'gateway' => [
'handler' => Gateway::class,
'listen' => 'tcp://0.0.0.0:11237',
'count' => 2,
'reloadable' => false,
'constructor' => ['config' => [
'lanIp' => '127.0.0.1',
'startPort' => 2300,
'registerAddress' => '127.0.0.1:1236',
'onConnect' => function(){},
]]
],
'worker' => [
'handler' => BusinessWorker::class,
'count' => 4,
'constructor' => ['config' => [
'eventHandler' => plugin\webman\gateway\Events::class,
'name' => 'ChatBusinessWorker',
'registerAddress' => '127.0.0.1:1236',
]]
],
'register' => [
'handler' => Register::class,
'listen' => 'text://127.0.0.1:1236',
'count' => 1, // Must be 1
'constructor' => []
],
];