webman中开启了两个gateway,对应的register分别为:127.0.0.1:6238和127.0.0.1:7238
当用下面的方法发送消息时,客户端有时收不到消息,也看不到报错信息(gateway-worker 版本 v3.1.0 )
Gateway::$registerAddress="127.0.0.1:7238"; Gateway::sendToUid("client1", json_encode($message));
可能你哪里配置错了,尤其是registerAddress
<?php use Webman\GatewayWorker\Gateway; use Webman\GatewayWorker\BusinessWorker; use Webman\GatewayWorker\Register; return [ 'gateway_ws' => [ 'handler' => Gateway::class, 'listen' => 'websocket://0.0.0.0:6272', 'count' => cpu_count(), 'reloadable' => false, 'constructor' => ['config' => [ 'lanIp' => '127.0.0.1', 'startPort' => 2300, 'pingInterval' => 25, 'pingNotResponseLimit' => 0, 'pingData' => '{"type":"ping"}', 'registerAddress' => '127.0.0.1:6238', 'onConnect' => function(){}, ]] ], 'gateway_tcp' => [ 'handler' => Gateway::class, 'listen' => 'tcp://0.0.0.0:6282', 'count' => cpu_count(), 'reloadable' => false, 'constructor' => ['config' => [ 'lanIp' => '127.0.0.1', 'startPort' => 2310, 'pingInterval' => 25, 'pingNotResponseLimit' => 0, 'pingData' => '{"type":"ping"}', 'registerAddress' => '127.0.0.1:6238', 'onConnect' => function(){}, ]] ], 'worker' => [ 'handler' => BusinessWorker::class, 'count' => cpu_count()*1, 'constructor' => ['config' => [ 'eventHandler' => plugin\webman\zy_videostream\Events::class, 'name' => 'ChatBusinessWorker', 'registerAddress' => '127.0.0.1:6238', ]] ], 'register' => [ 'handler' => Register::class, 'listen' => 'text://0.0.0.0:6238', 'count' => 1, // Must be 1 'constructor' => [] ], ];
<?php use Webman\GatewayWorker\Gateway; use Webman\GatewayWorker\BusinessWorker; use Webman\GatewayWorker\Register; return [ 'gateway_ws' => [ 'handler' => Gateway::class, 'listen' => 'websocket://0.0.0.0:7272', 'count' => cpu_count(), 'reloadable' => false, 'constructor' => ['config' => [ 'lanIp' => '127.0.0.1', 'startPort' => 2400, 'pingInterval' => 3, 'pingNotResponseLimit' => 0, 'pingData' => '{"code":"ping"}', 'registerAddress' => '127.0.0.1:7238', 'onConnect' => function(){}, ]] ], 'gateway_tcp' => [ 'handler' => Gateway::class, 'listen' => 'tcp://0.0.0.0:7282', 'count' => cpu_count(), 'reloadable' => false, 'constructor' => ['config' => [ 'lanIp' => '127.0.0.1', 'startPort' => 2410, 'pingInterval' => 3, 'pingNotResponseLimit' => 0, 'pingData' => '{"code":"ping"}', 'registerAddress' => '127.0.0.1:7238', 'onConnect' => function(){}, ]] ], 'worker' => [ 'handler' => BusinessWorker::class, 'count' => cpu_count()*1, 'constructor' => ['config' => [ 'eventHandler' => plugin\webman\zy_fzb\Events::class, 'name' => 'FzbBusinessWorker', 'registerAddress' => '127.0.0.1:7238', ]] ], 'register' => [ 'handler' => Register::class, 'listen' => 'text://0.0.0.0:7238', 'count' => 1, // Must be 1 'constructor' => [] ], ];
配置没问题的话可能是逻辑哪里有问题,比如连接没绑定uid或者连接已经断开或者uid是错的等等,其它人没办法给你排查,需要自己定位下
好的,谢谢
已解决 添加Gateway::$addressesCacheDisable=true;就可以了
在哪里配置的Gateway::$addressesCacheDisable=true
同问,在有2个Gateway配置的情况下,AB分别连2个Gateway端口,getAllUidList时只能获得其中一个
可能你哪里配置错了,尤其是registerAddress
检查了下registerAddress好像没问题
配置没问题的话可能是逻辑哪里有问题,比如连接没绑定uid或者连接已经断开或者uid是错的等等,其它人没办法给你排查,需要自己定位下
好的,谢谢
已解决
添加Gateway::$addressesCacheDisable=true;就可以了
在哪里配置的Gateway::$addressesCacheDisable=true
同问,在有2个Gateway配置的情况下,AB分别连2个Gateway端口,getAllUidList时只能获得其中一个