gateway单台设备连接不稳定的问题如何排查原因呢?

ximengxuan

问题描述

gateway-worker服务端以debug模式启动后,连接了一台客户端。
这台客户端出现多个onConnect事件后,终于连接上了,并向服务端发送一条消息。
过了一会有出现了多个onClose事件。

接下来就是反复的在onConnect和onClose之间,一直握手、关闭。
服务端重启服务后,客户端又能连上了。
过一会又会出现上述问题。

这是因为客户端的网络不稳定,还是服务端的网络不稳定呢,或者是其他原因导致的呢?

[2024-08-31 10:49:38] [onConnect] client_id:7f0000010b540000000c client:192.168.2.10:37136 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:49:38] [onConnect] client_id:7f0000010b540000000b client:192.168.2.10:37134 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:49:38] [onConnect] client_id:7f0000010b540000000d client:192.168.2.10:37140 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:49:38] [onConnect] client_id:7f0000010b540000000e client:192.168.2.10:37146 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:49:38] [onConnect] client_id:7f0000010b5500000008 client:192.168.2.10:37150 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:49:38] [onConnect] client_id:7f0000010b5500000009 client:192.168.2.10:37154 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:49:38] [onConnect] client_id:7f0000010b540000000f client:192.168.2.10:37158 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:49:43] [onMessage] client_id:7f0000010b5500000006 client:192.168.2.10:37110 gateway:127.0.0.1:8282 session:{"auth_timer_id":3,"imei":"00008030-000378203A87802E"} onMessage:{"type":"CLIENT_CONNECT","username":"test","imei":"00008030-000378203A87802E","name":"iPhone","screen_size":"750 x 1334","battery":"100%","is_charging":0,"is_screen_on":1,"model":"iPhone","app_version":"3.18.0","iec_version":42,"service_state":1,"exp_time":"2024-11-18 20:46:02","connect_mode":"long","platform":"easyclick_ios"}
[2024-08-31 10:49:48] [onMessage] client_id:7f0000010b5500000006 client:192.168.2.10:37110 gateway:127.0.0.1:8282 session:{"auth_timer_id":3,"imei":"00008030-000378203A87802E"} onMessage:{"type":"CLIENT_CONNECT","username":"test","imei":"00008030-000378203A87802E","name":"iPhone","screen_size":"750 x 1334","battery":"100%","is_charging":0,"is_screen_on":1,"model":"iPhone","app_version":"3.18.0","iec_version":42,"service_state":1,"exp_time":"2024-11-18 20:46:02","connect_mode":"long","platform":"easyclick_ios"}
[2024-08-31 10:49:54] [onMessage] client_id:7f0000010b5500000006 client:192.168.2.10:37110 gateway:127.0.0.1:8282 session:{"auth_timer_id":3,"imei":"00008030-000378203A87802E"} onMessage:{"type":"CLIENT_CONNECT","username":"test","imei":"00008030-000378203A87802E","name":"iPhone","screen_size":"750 x 1334","battery":"100%","is_charging":0,"is_screen_on":1,"model":"iPhone","app_version":"3.18.0","iec_version":42,"service_state":1,"exp_time":"2024-11-18 20:46:02","connect_mode":"long","platform":"easyclick_ios"}
[2024-08-31 10:49:59] [onMessage] client_id:7f0000010b5500000006 client:192.168.2.10:37110 gateway:127.0.0.1:8282 session:{"auth_timer_id":3,"imei":"00008030-000378203A87802E"} onMessage:{"type":"CLIENT_CONNECT","username":"test","imei":"00008030-000378203A87802E","name":"iPhone","screen_size":"750 x 1334","battery":"100%","is_charging":0,"is_screen_on":1,"model":"iPhone","app_version":"3.18.0","iec_version":42,"service_state":1,"exp_time":"2024-11-18 20:46:02","connect_mode":"long","platform":"easyclick_ios"}
[2024-08-31 10:50:04] [onMessage] client_id:7f0000010b5500000006 client:192.168.2.10:37110 gateway:127.0.0.1:8282 session:{"auth_timer_id":3,"imei":"00008030-000378203A87802E"} onMessage:{"type":"CLIENT_CONNECT","username":"test","imei":"00008030-000378203A87802E","name":"iPhone","screen_size":"750 x 1334","battery":"100%","is_charging":0,"is_screen_on":1,"model":"iPhone","app_version":"3.18.0","iec_version":42,"service_state":1,"exp_time":"2024-11-18 20:46:02","connect_mode":"long","platform":"easyclick_ios"}
[2024-08-31 10:50:08] onClose >>> client_id:7f0000010b5500000007 client:192.168.2.10:37114 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:08] onClose >>> client_id:7f0000010b540000000c client:192.168.2.10:37136 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:08] onClose >>> client_id:7f0000010b540000000b client:192.168.2.10:37134 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:08] onClose >>> client_id:7f0000010b540000000d client:192.168.2.10:37140 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:08] onClose >>> client_id:7f0000010b540000000e client:192.168.2.10:37146 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:08] onClose >>> client_id:7f0000010b5500000008 client:192.168.2.10:37150 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:08] onClose >>> client_id:7f0000010b5500000009 client:192.168.2.10:37154 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:08] onClose >>> client_id:7f0000010b540000000f client:192.168.2.10:37158 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:09] [onMessage] client_id:7f0000010b5500000006 client:192.168.2.10:37110 gateway:127.0.0.1:8282 session:{"auth_timer_id":3,"imei":"00008030-000378203A87802E"} onMessage:{"type":"CLIENT_CONNECT","username":"test","imei":"00008030-000378203A87802E","name":"iPhone","screen_size":"750 x 1334","battery":"100%","is_charging":0,"is_screen_on":1,"model":"iPhone","app_version":"3.18.0","iec_version":42,"service_state":1,"exp_time":"2024-11-18 20:46:02","connect_mode":"long","platform":"easyclick_ios"}
[2024-08-31 10:50:14] [onMessage] client_id:7f0000010b5500000006 client:192.168.2.10:37110 gateway:127.0.0.1:8282 session:{"auth_timer_id":3,"imei":"00008030-000378203A87802E"} onMessage:{"type":"CLIENT_CONNECT","username":"test","imei":"00008030-000378203A87802E","name":"iPhone","screen_size":"750 x 1334","battery":"100%","is_charging":0,"is_screen_on":1,"model":"iPhone","app_version":"3.18.0","iec_version":42,"service_state":1,"exp_time":"2024-11-18 20:46:02","connect_mode":"long","platform":"easyclick_ios"}
[2024-08-31 10:50:19] [onMessage] client_id:7f0000010b5500000006 client:192.168.2.10:37110 gateway:127.0.0.1:8282 session:{"auth_timer_id":3,"imei":"00008030-000378203A87802E"} onMessage:{"type":"CLIENT_CONNECT","username":"test","imei":"00008030-000378203A87802E","name":"iPhone","screen_size":"750 x 1334","battery":"100%","is_charging":0,"is_screen_on":1,"model":"iPhone","app_version":"3.18.0","iec_version":42,"service_state":1,"exp_time":"2024-11-18 20:46:02","connect_mode":"long","platform":"easyclick_ios"}
[2024-08-31 10:50:28] onClose >>> client_id:7f0000010b5500000006 client:192.168.2.10:37110 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:28] [onConnect] client_id:7f0000010b550000000a client:192.168.2.10:37188 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:50:34] onClose >>> client_id:7f0000010b550000000a client:192.168.2.10:37188 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:34] [onConnect] client_id:7f0000010b550000000b client:192.168.2.10:37192 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:50:46] onClose >>> client_id:7f0000010b550000000b client:192.168.2.10:37192 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:50:46] [onConnect] client_id:7f0000010b5400000010 client:192.168.2.10:37196 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:51:11] onClose >>> client_id:7f0000010b5400000010 client:192.168.2.10:37196 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:51:11] [onConnect] client_id:7f0000010b5400000011 client:192.168.2.10:37198 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:51:41] onClose >>> client_id:7f0000010b5400000011 client:192.168.2.10:37198 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:51:59] [onConnect] client_id:7f0000010b550000000c client:192.168.2.10:37206 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:52:29] onClose >>> client_id:7f0000010b550000000c client:192.168.2.10:37206 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:53:37] [onConnect] client_id:7f0000010b550000000d client:192.168.2.10:37216 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:54:07] onClose >>> client_id:7f0000010b550000000d client:192.168.2.10:37216 gateway:127.0.0.1:8282  onClose:''
[2024-08-31 10:56:51] [onConnect] client_id:7f0000010b5400000012 client:192.168.2.10:37240 gateway:127.0.0.1:8282 onConnect:''
[2024-08-31 10:57:21] onClose >>> client_id:7f0000010b5400000012 client:192.168.2.10:37240 gateway:127.0.0.1:8282  onClose:''

操作系统及workerman/webman等框架组件具体版本

Workerman version:4.1.10
PHP version:7.4.33
workerman/gateway-worker v3.0.28

241 1 0
1个回答

keytehu

应该是start_gateway.php里设置了30秒客户端不发心跳关闭连接,连接关闭后客户端又重连,如此反复。属于客户端问题。
贴下你的 start_gateway.php 看看

  • ximengxuan 2024-08-31

    谢谢解答。start_gateway.php里设置的是55秒。客户端心跳包间隔是50秒。服务端有做身份鉴权。排除身份不正确被踢的情况。

  • keytehu 2024-08-31

    tcpdump抓包看下是客户端关闭的连接还是服务端,从而定位是哪一端的问题,具体命令及结果可以问AI

×
🔝