它设置为每 5 秒向服务器发送一次 PING。最初,每 5 秒发送一次 ping。自该计划开始以来已经过去了一个月。目前,ping 每秒向服务器发送 2-3 次。“vertx.setPeriodic”函数中似乎有一个BUG。
long[] pID = {0};
pID[0] = vertx.setPeriodic(5000, handler -> {
sendHTTP2PING(mapKey, conn);
});
private void sendHTTP2PING(String mapKey, HttpConnection conn) {
conn.ping(pingData, pong -> {
if(pong.succeeded()) {
localAddressPort = conn.localAddress().port();
logger.info("[HTTP/2 CLIENT PING] RECEIVED PONG");
} else {
logger.info("[HTTP/2 CLIENT PING] DOES NOT RECEIVED PONG...!!!");
disconnectToServer(mapKey);
}
}).closeHandler(ch -> {
disconnectToServer(mapKey);
}).exceptionHandler(exh -> {
disconnectToServer(mapKey);
});
}
日志文件
2020-10-27 16:13:10 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:10 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:11 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:11 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:11 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:12 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:12 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:13 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:15 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:15 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:16 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:16 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:16 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:17 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:17 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:18 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:20 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!
2020-10-27 16:13:20 [vert.x-eventloop-thread-2] - [HTTP/2 CLIENT PING] 没有收到 PONG ......!!!