private void handleKeepAliveTimeout() { if (!ctx.channel().isOpen()) { return; } if (!isHandshakeCompleted()) { log.warn("[{}] Pulsar Handshake was not completed within timeout, closing connection", ctx.channel()); ctx.close(); } else if (waitingForPingResponse && ctx.channel().config().isAutoRead()) { // We were waiting for a response and another keep-alive just completed. // If auto-read was disabled, it means we stopped reading from the connection, so we might receive the Ping // response later and thus not enforce the strict timeout here. log.warn("[{}] Forcing connection to close after keep-alive timeout", ctx.channel()); ctx.close(); } else if (remoteEndpointProtocolVersion >= ProtocolVersion.v1.getNumber()) { // Send keep alive probe to peer only if it supports the ping/pong commands, added in v1 if (log.isDebugEnabled()) { log.debug("[{}] Sending ping message", ctx.channel()); } waitingForPingResponse = true; ctx.writeAndFlush(Commands.newPing()); } else { if (log.isDebugEnabled()) { log.debug("[{}] Peer doesn't support keep-alive", ctx.channel()); } } }
private void handleKeepAliveTimeout() { if (!ctx.channel().isOpen()) { return; } if (!isHandshakeCompleted()) { log.warn("[{}] Pulsar Handshake was not completed within timeout, closing connection", ctx.channel()); ctx.close(); } else if (waitingForPingResponse && ctx.channel().config().isAutoRead()) { // We were waiting for a response and another keep-alive just completed. // If auto-read was disabled, it means we stopped reading from the connection, so we might receive the Ping // response later and thus not enforce the strict timeout here. log.warn("[{}] Forcing connection to close after keep-alive timeout", ctx.channel()); ctx.close(); } else if (remoteEndpointProtocolVersion >= ProtocolVersion.v1.getNumber()) { // Send keep alive probe to peer only if it supports the ping/pong commands, added in v1 if (log.isDebugEnabled()) { log.debug("[{}] Sending ping message", ctx.channel()); } waitingForPingResponse = true; ctx.writeAndFlush(Commands.newPing()); } else { if (log.isDebugEnabled()) { log.debug("[{}] Peer doesn't support keep-alive", ctx.channel()); } } }