首页
下载
文档
问答社区
视频
捐赠
源代码
AI 助理
赞助商
CRMEB
Apipost
腾讯云
微擎
禅道
51Talk
商业产品
Swoole AI 智能文档翻译器
Swoole-Compiler PHP 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
connection_info并发下出错
在做压力测试的时候 并发40 ,发现通过connection_info获取到的remote_ip有时候为'',有时候为'::',代码如下,不知道什么原因。。。   ``` $server_list = $this->config['server_list']; for ($i = 0; $i < count($server_list); $i++) { $fdInfo = $serv->connection_info($fd); //发现数据源的IP和当前循环的IP不同时才进行发送(防止重复发送) //这里有点有危险,如果判断失败,把消息又发回数据源的服务器,那么会陷入发送循环 if($fdInfo['remote_ip'] != $server_list[$i]){ $client = new \swoole_client(SWOOLE_SOCK_TCP); if ($client->connect($server_list[$i], $this->config['tcp']['port'], 0.5)) { Tools::logger("send message to {$server_list[$i]} "); $client->send($data); } unset($client); $serv->close($fd); } } ``` 打印了下fdInfo的值,fdInfo:false,send to 10.66.*.98
发布于7年前 · 1 次浏览 · 来自
提问
T
Turbocc
在做压力测试的时候 并发40 ,发现通过connection_info获取到的remote_ip有时候为'',有时候为'::',代码如下,不知道什么原因。。。   ``` $server_list = $this->config['server_list']; for ($i = 0; $i < count($server_list); $i++) { $fdInfo = $serv->connection_info($fd); //发现数据源的IP和当前循环的IP不同时才进行发送(防止重复发送) //这里有点有危险,如果判断失败,把消息又发回数据源的服务器,那么会陷入发送循环 if($fdInfo['remote_ip'] != $server_list[$i]){ $client = new \swoole_client(SWOOLE_SOCK_TCP); if ($client->connect($server_list[$i], $this->config['tcp']['port'], 0.5)) { Tools::logger("send message to {$server_list[$i]} "); $client->send($data); } unset($client); $serv->close($fd); } } ``` 打印了下fdInfo的值,fdInfo:false,send to 10.66.*.98
赞
0
分享
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
评论
2017-11-24
乱
乱事重生
问题已解决,我的配置dispatch_mode 设的是3,改成2并发就没什么问题了 附文档:dispatch_mode=1/3时,底层会屏蔽onConnect/onClose事件,原因是这2种模式下无法保证onConnect/onClose/onReceive的顺序 非请求响应式的服务器程序,请不要使用模式1或3
赞
0
回复
2018-10-25
木
木子学才
好吧 dispatch_mode=1/3的时候 connection_info在并发情况下就获取不到了,全是false,尴尬,其他模式分发效果又不适合
赞
0
回复
微信公众号
热门内容
暂无回复的问答
- CodeGalaxy K3s 轻量集群节点之间如何实现负载均衡
- 关于openssl CURL WARNING swSSL_connect: SSL_connect(fd=69) failed. Error: error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small[1|394]
- 多个模型如何进行事务异常回退?
- websocket开启wss报错
- 协程tcp服务器如何使用多进程?recv()方法接收信息,打印出来的pid一直是同一个。没用使用到多进程啊。