A、B服务器可以通过内网IP访问,A服务器和客户端建立连接,B服务器想通过sendToClient给客户端发消息,
A、B的process.php要怎么配置呢
return [
'gateway' => [
'handler' => Gateway::class,
'listen' => 'websocket://0.0.0.0:7272',
'count' => cpu_count(),
'reloadable' => false,
'constructor' => ['config' => [
'lanIp' => '127.0.0.1',
'startPort' => 2300,
'pingInterval' => 20,
'pingNotResponseLimit' => 1,
'pingData' => '',
'registerAddress' => '127.0.0.1:1236',
'onConnect' => function(){},
]]
],
'worker' => [
'handler' => BusinessWorker::class,
'count' => cpu_count()*2,
'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' => []
]
]
B不用设置process,B服务器使用gatewayClient就可以给A服务器的客户端发消息。
https://www.workerman.net/doc/gateway-worker/push-in-other-project.html
还有个问题,A服务器的1236端口在云服务商和宝塔都放行了,但在B服务器telnet端口不通呢
解决了,要把A服务器register监听改为0.0.0.0:1236