GatewayWorker
GatewayWorker copied to clipboard
在同一次请求中,无法向不同的gateway发送数据
Gateway::$registerAddress = '172.17.16.7:5000';
Gateway::sendToUid(10120,$msg);
Gateway::$registerAddress = '172.17.16.5:5000';
Gateway::sendToUid(10100,$msg);
第二个会失败,打印日志里,数据还是发送到第一个的gateway中
PHP 7.3.19环境
Gateway::$registerAddress = 'xxxx';
GatewayWorker 里没有这种用法。这个是GatewayClient的用法。
GatewayWorker\Lib\Gateway::$registerAddress = 'xxxx';
不是这样用么?
GatewayWorker里不支持设置GatewayWorker\Lib\Gateway::$registerAddress
代码:
$msg = ['path'=>'gateway-172.17.16.7:5000'];
$msg = json_encode($msg);
\GatewayClient\Gateway::$registerAddress = '172.17.16.7:5000';
dump(11111);
dump(\GatewayClient\Gateway::isUidOnline(10120));
\GatewayClient\Gateway::sendToUid(10120,$msg);
\GatewayClient\Gateway::$registerAddress = '172.17.16.5:5000';
dump(2222);
dump(\GatewayClient\Gateway::isUidOnline(10118));
$data=['path'=>'gateway-172.17.16.5:5000'];
$data = json_encode($data);
\GatewayClient\Gateway::sendToUid(10118,$data);
日志:
[2020-09-01T17:47:06+08:00][error] 172.17.16.7:2000
[2020-09-01T17:47:06+08:00][error] F[10120]{"path":"gateway-172.17.16.7:5000"}
[2020-09-01T17:47:06+08:00][error] 172.17.16.7:2001
[2020-09-01T17:47:06+08:00][error] F[10120]{"path":"gateway-172.17.16.7:5000"}
[2020-09-01T17:47:06+08:00][error] 172.17.16.7:2003
[2020-09-01T17:47:06+08:00][error] F[10120]{"path":"gateway-172.17.16.7:5000"}
[2020-09-01T17:47:06+08:00][error] 172.17.16.7:2002
[2020-09-01T17:47:06+08:00][error] F[10120]{"path":"gateway-172.17.16.7:5000"}
[2020-09-01T17:47:06+08:00][error] 172.17.16.7:2000
[2020-09-01T17:47:06+08:00][error] F[10118]{"path":"gateway-172.17.16.5:5000"}
[2020-09-01T17:47:06+08:00][error] 172.17.16.7:2001
[2020-09-01T17:47:06+08:00][error] F[10118]{"path":"gateway-172.17.16.5:5000"}
[2020-09-01T17:47:06+08:00][error] 172.17.16.7:2003
[2020-09-01T17:47:06+08:00][error] F[10118]{"path":"gateway-172.17.16.5:5000"}
[2020-09-01T17:47:06+08:00][error] 172.17.16.7:2002
[2020-09-01T17:47:06+08:00][error] F[10118]{"path":"gateway-172.17.16.5:5000"}
断点打在\GatewayClient\Gateway
的1212
行
foreach ($all_addresses as $address) {
Utils::error($address);
Utils::error($buffer);
static::sendBufferToGateway($address, $buffer);
}
解决了吗?你应该在https://github.com/walkor/GatewayClient这里提交bug。我也遇到了这个问题
解决了吗?你应该在https://github.com/walkor/GatewayClient 这里提交bug。我也遇到了这个问题
最后通过异步队列实现的,但这个问题还是在。