Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在同一次请求中,无法向不同的gateway发送数据 #73

Open
liuqiandev opened this issue Sep 1, 2020 · 9 comments
Open

在同一次请求中,无法向不同的gateway发送数据 #73

liuqiandev opened this issue Sep 1, 2020 · 9 comments

Comments

@liuqiandev
Copy link

Gateway::$registerAddress = '172.17.16.7:5000';
Gateway::sendToUid(10120,$msg);
Gateway::$registerAddress = '172.17.16.5:5000';
Gateway::sendToUid(10100,$msg);

第二个会失败,打印日志里,数据还是发送到第一个的gateway中

@liuqiandev
Copy link
Author

PHP 7.3.19环境

@walkor
Copy link
Owner

walkor commented Sep 1, 2020

Gateway::$registerAddress = 'xxxx';

GatewayWorker 里没有这种用法。这个是GatewayClient的用法。

@liuqiandev
Copy link
Author

GatewayWorker\Lib\Gateway::$registerAddress = 'xxxx';
不是这样用么?

@walkor
Copy link
Owner

walkor commented Sep 1, 2020

GatewayWorker里不支持设置GatewayWorker\Lib\Gateway::$registerAddress

@liuqiandev
Copy link
Author

代码:

        $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"}

@liuqiandev
Copy link
Author

断点打在\GatewayClient\Gateway1212

            foreach ($all_addresses as $address) {
                Utils::error($address);
                Utils::error($buffer);
                static::sendBufferToGateway($address, $buffer);
            }

@dignfei
Copy link

dignfei commented Apr 30, 2021

@dignfei
Copy link

dignfei commented Apr 30, 2021

解决了吗?你应该在https://github.com/walkor/GatewayClient 这里提交bug。我也遇到了这个问题

@liuqiandev
Copy link
Author

最后通过异步队列实现的,但这个问题还是在。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants