Interface H2ProtocolConfig.KeepAlivePolicy

Enclosing interface:
H2ProtocolConfig

public static interface H2ProtocolConfig.KeepAlivePolicy
A policy for sending PING frames to the peer.

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 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-alive PING frames. In this case, ackTimeout() is still used for PING acknowledgment during graceful closure process between two GOAWAY frames.

      Returns:
      Duration of time the connection has to be idle before a ping is sent or Duration.ZERO to disable keep-alive PING 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() is zero, this timeout is still used for PING acknowledgment during graceful closure process between two GOAWAY frames.

      Returns:
      Duration to wait for acknowledgment from the peer after a ping is sent.
    • 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.