GatewayWorker分布式部署 bindUid 绑定失效

czwe

问题描述

GatewayWorker分布式部署
配置三台服务器start_gateway.php start_businessworker.php中的registerAddress为['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236']。

设备A 连接接了192.168.1.1 会随机分配 businessworker 1,2,3台来处理信息进行bindUid 绑定

而192.168.1.1 在发送信息 isUidOnline,sendToUid 都是失败了

//第一台192.168.1.1
//start_gateway.php
$gateway_package = new Gateway("tcp://0.0.0.0:8090");
$gateway_package->name = 'GatewayPackage1';
$gateway_package->count = 4;
$gateway_package->lanIp = '192.168.1.1';
$gateway_package->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];
$gateway_package->startPort = 9566;
$gateway_package->pingInterval = 30;
$gateway_package->pingNotResponseLimit = 2;

// bussinessWorker 进程
$worker = new BusinessWorker();
// worker名称
$worker->name = 'YourAppBusinessWorker1';
// bussinessWorker进程数量
$worker->count = 4;

$worker->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];

//第二台192.168.1.2
//start_gateway.php
$gateway_package = new Gateway("tcp://0.0.0.0:8090");
$gateway_package->name = 'GatewayPackage2';
$gateway_package->count = 4;
$gateway_package->lanIp = '192.168.1.2';
$gateway_package->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];
$gateway_package->startPort = 9566;
$gateway_package->pingInterval = 30;
$gateway_package->pingNotResponseLimit = 2;

// bussinessWorker 进程
$worker = new BusinessWorker();
// worker名称
$worker->name = 'YourAppBusinessWorker2';
// bussinessWorker进程数量
$worker->count = 4;

$worker->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];

//第三台192.168.1.3
//start_gateway.php
$gateway_package = new Gateway("tcp://0.0.0.0:8090");
$gateway_package->name = 'GatewayPackage3';
$gateway_package->count = 4;
$gateway_package->lanIp = '192.168.1.3';
$gateway_package->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];
$gateway_package->startPort = 9566;
$gateway_package->pingInterval = 30;
$gateway_package->pingNotResponseLimit = 2;

// bussinessWorker 进程
$worker = new BusinessWorker();
// worker名称
$worker->name = 'YourAppBusinessWorker3';
// bussinessWorker进程数量
$worker->count = 4;

$worker->registerAddress = ['192.168.1.1:1236','192.168.1.2:1236','192.168.1.3:1236'];

tcp连接192.168.1.1:8090 bussinessWorker 是随机分配 1,2,3 台服务器来进行绑定 bindUid 绑定uid

可是这样绑定不上 是我的配置有问题还是bindUid 不能互通 ABC 台服务器 可以是B上线 A在根据绑定信息发送指令就不行了

383 2 0
2个回答

释永战

你方向搞错了,register只要一台,business多台就可以了····

  • czwe 2024-05-23

    麻烦看一下我的分布式配置对吗

Gin

1、注意多机部署时以下端口不要被服务器安全组阻挡:

①、Register服务监听的端口要可以被其它内网服务器访问(为了安全,register要监听内网ip不能让其被外网访问);

②、start_gateway.php中如果$gateway->startPort=2300; $gateway->count=4;,则2300 2301 2302 2303四个端口需要被设置成能被其它服务器访问,也就是起始端口$gateway->startPort到$gateway->startPort + $gateway->count - 1这 $gateway->count个端口要设置成能被其它内网服务器访问。

  • czwe 2024-05-23

    内网端口都开放了 在分配的时候是随机的 是不是要固定一下路由 ip1过来的就是ip处理 是不是就能解决上线bindUid 失败的问题

  • Gin 2024-05-23

    理论上应该是能互通的, 你客户端有心跳发送没有, 是不是服务端主动给踢掉线了

×
🔝