GatewayWorker icon indicating copy to clipboard operation
GatewayWorker copied to clipboard

\GatewayClient\Gateway::sendToGroup在高并发场景中很难确保发送成功

Open tourze opened this issue 3 years ago • 1 comments

最近在一个大流量活动中使用了Workerman/GatewayWorker,发现在后台群推消息时,偶发会出现部分接收方无法接收消息的问题。

日志中表现为:

image

大概就是在

        } // 运行在其它环境中,通过注册中心得到gateway地址
        else {
            $addresses = static::getAllGatewayAddressesFromRegister();
            foreach ($addresses as $address) {
                $gateway_data['ext_data'] = isset($address_connection_array[$address]) ?
                    json_encode(array('group'=> $group, 'exclude'=> $address_connection_array[$address])) :
                    $default_ext_data_buffer;
                static::sendToGateway($address, $gateway_data);
            }
        }

这里获取得到gateway地址后循环调用发送。但是如果循环过程中有一个gateway挂了,后面就无法发送了。

tourze avatar May 24 '21 09:05 tourze

我当初遇到的好像也是这个问题,自己读代码解决了,前提是你已经按照官方文档做了系统优化了,也使用了event扩展

image

caiqy avatar Jun 02 '21 10:06 caiqy