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 TypeMethodDescriptionboolean
Whether this policy allows to send pings even if there are no streams active on the connection.
-
Method Details
-
idleDuration
Duration idleDuration()Duration
of 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.ZERO
disables keep-alivePING
frames. In this case,ackTimeout()
is still used forPING
acknowledgment during graceful closure process between two GOAWAY frames.- Returns:
Duration
of time the connection has to be idle before a ping is sent orDuration.ZERO
to disable keep-alivePING
frames.
-
ackTimeout
Duration ackTimeout()Duration
to 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
PING
frames ara acknowledged immediately.When
idleDuration()
iszero
, this timeout is still used forPING
acknowledgment 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:
true
if this policy allows to send pings even if there are no streams active on the connection.
-