Interface H2ProtocolConfig.KeepAlivePolicy
- Enclosing interface:
- H2ProtocolConfig
While idleDuration() and ackTimeout()} can be configured independently, users should keep
them reasonably aligned. When idle duration is positive, the system expects to receive
PING acknowledgment before it can send the following PING frames. A good practice is to keep
ackTimeout() less than or equal to idleDuration()}. Otherwise, the following PING
frames can be delayed awaiting acknowledgment of the previous one.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this policy allows to send pings even if there are no streams active on the connection.
-
Method Details
-
idleDuration
Duration idleDuration()Durationof time the connection has to be idle before a ping is sent.Too short idle duration can be used for testing but may cause unnecessarily high network traffic in real environments.
Duration.ZEROdisables keep-alivePINGframes. In this case,ackTimeout()is still used forPINGacknowledgment during graceful closure process between two GOAWAY frames.- Returns:
Durationof time the connection has to be idle before a ping is sent orDuration.ZEROto disable keep-alivePINGframes.
-
ackTimeout
Duration ackTimeout()Durationto wait for acknowledgment from the peer after a ping is sent. If no acknowledgment is received within the configured timeout, a connection will be closed.This duration must be positive. Too short ack timeout can cause undesirable connection closures. Too long ack timeout can add unnecessary delay when the remote peer is unresponsive or the network connection is broken, because under normal circumstances
PINGframes ara acknowledged immediately.When
idleDuration()iszero, this timeout is still used forPINGacknowledgment during graceful closure process between two GOAWAY frames. -
withoutActiveStreams
boolean withoutActiveStreams()Whether this policy allows to send pings even if there are no streams active on the connection.- Returns:
trueif this policy allows to send pings even if there are no streams active on the connection.
-