GatewayWorker给对方发送不出消息
tcpdump抓包可以看到对方向我传输的消息,但是但是就是发不出去,onmessage也没进入
我现在给对方强制下线也无效,消息根本就发送不出去,一直显示客户端在线
这是抓包信息
12:49:44.869009 IP 103.43.71.160.53438 > 172.17.251.248.80: Flags [P.], seq 3425:3450, ack 1, win 0, options [nop,nop,TS val 3456180314 ecr 3592720976], length 25
$..S...................Pi.
.. Z.$.P......{"ping":1753418984}
12:49:44.869012 IP 172.17.251.248.80 > 103.43.71.160.53438: Flags [.], ack 3450, win 122, options [nop,nop,TS val 3592730708 ecr 3456180314], length 0
=...zoG.........g+G..P....S.i.
.$.T.. Z
12:49:54.625646 IP 103.43.71.160.53438 > 172.17.251.248.80: Flags [P.], seq 3450:3475, ack 1, win 0, options [nop,nop,TS val 3456190070 ecr 3592730708], length 25
=..S...................Pi.
..Fv.$.T......{"ping":1753418994}
12:49:54.625652 IP 172.17.251.248.80 > 103.43.71.160.53438: Flags [.], ack 3475, win 122, options [nop,nop,TS val 3592740465 ecr 3456190070], length 0
V...z"..........g+G..P....S.i.
.$.q..Fv
12:49:59.489229 IP 103.43.71.160.53438 > 172.17.251.248.80: Flags [P.], seq 3475:3500, ack 1, win 0, options [nop,nop,TS val 3456194934 ecr 3592740465], length 25
V..S......~............Pi.
..Yv.$.q......{"ping":1753418999}
12:49:59.489236 IP 172.17.251.248.80 > 103.43.71.160.53438: Flags [.], ack 3500, win 122, options [nop,nop,TS val 3592745328 ecr 3456194934], length 0
o...z...........g+G..P....S.i.
.$.p..Yv
这是onmessage,onmessage消息都打印不出来。
public static function onMessage($client_id, $message)
{
//格式:{"Key":"PMAU,HSI"} {"ping":10位时间戳}
$data = json_decode($message, true);
//心跳检测
if(isset($data['ping']) && !empty($data['ping'])) {
$currentTime = time();
// 检查是否超过心跳间隔
if (!isset(self::$lastHeartbeatTime[$client_id]) || ($currentTime - self::$lastHeartbeatTime[$client_id] >= self::$heartbeatInterval)) {
self::$lastHeartbeatTime[$client_id] = $currentTime; // 更新心跳时间
Gateway::sendToClient($client_id, json_encode(['pong' => $currentTime]));
}
$ip_list = Gateway::getSession($client_id);
if(!empty($ip_list)) {
$ip = $ip_list['ip'];
echo "IP【".$ip."】client_id心跳检测【".$client_id."】".PHP_EOL;
}
return;
}
}
我现在给对方强制下线也无效,消息根本就发送不出去,一直显示客户端在线
use \GatewayWorker\Lib\Gateway;
Gateway::$registerAddress = '127.0.0.1:1233';
$client_id = "7f0000010b5400000050";
// 检查客户端是否在线
if(Gateway::isOnline($client_id)) {
echo "客户端在线";
} else {
echo "客户端不在线";
}
//Gateway::sendToClient("7f0000010b540000005e",json_encode(['pong' => 111111111111111111111111111111111111111111111111111111111111111111111111]));
Gateway::closeClient($client_id);
和使用nginx代理有关系吗?但是其他客户端能正常收到消息
server
{
listen 80;
server_name 127.0.0.1;
index index.html index.htm index.php;