public final class Http2ConnectionLiveness extends Object implements HttpConnectionLiveness
This class implements liveness detection for HTTP/2 connections by sending PING frames when the connection becomes idle (no read/write activity). The peer must respond with a PING ACK within the configured timeout, otherwise the connection is considered unresponsive.
pingAckTimeoutpingAckDropThreshold timesThis class is designed to be used with a single channel. All operations, including scheduled tasks, execute on the channel's event loop thread, eliminating the need for explicit synchronization. A new instance is created per channel.
CLOSE, log| Constructor and Description |
|---|
Http2ConnectionLiveness(Http2FrameCodec http2FrameCodec,
int pingAckDropThreshold,
long pingAckTimeoutNanos)
Constructs a new
Http2ConnectionLiveness instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancels the scheduled ping task.
|
void |
check(ChannelHandlerContext ctx)
Checks the liveness of the connection and schedules a ping if necessary.
|
void |
receive(Object msg)
Receives a message from the peer and processes it if it is a ping frame.
|
public Http2ConnectionLiveness(Http2FrameCodec http2FrameCodec, int pingAckDropThreshold, long pingAckTimeoutNanos)
Http2ConnectionLiveness instance.http2FrameCodec - the HTTP/2 frame codecpingAckDropThreshold - the maximum number of PING frame transmission attempts before closing the connectionpingAckTimeoutNanos - the timeout in nanoseconds for receiving a PING ACK responsepublic void cancel()
cancel in interface HttpConnectionLivenesspublic void check(ChannelHandlerContext ctx)
check in interface HttpConnectionLivenessctx - the ChannelHandlerContext of the connectionpublic void receive(Object msg)
receive in interface HttpConnectionLivenessmsg - the message received from the peer