Http2ClientTransport constructor
- SecurityContext? context,
- Duration? pingInterval,
- Duration pingTimeout = const Duration(seconds: 15),
- bool pingIdleConnections = false,
- Duration idleConnectionTimeout = const Duration(minutes: 15),
The default implementation manages HTTP/2 connections and keeps them alive with PING frames.
The logic is based on "Basic Keepalive" described in https://github.com/grpc/proposal/blob/0ba0c1905050525f9b0aee46f3f23c8e1e515489/A8-client-side-keepalive.md#basic-keepalive as well as the client channel arguments described in https://github.com/grpc/grpc/blob/8e137e524a1b1da7bbf4603662876d5719563b57/doc/keepalive.md
idleConnectionTimeout
will close a connection if the time since the last request stream
exceeds this value. Defaults to 15 minutes.
pingInterval
is interval to send PING frames to keep a connection alive.
If a PING frame is not responded to within pingTimeout
, the connection and all open streams close.
By default, no PING frames are sent. If a value is provided, PING frames
are sent only for connections that have open streams, unless
pingIdleConnections
is enabled.
Sensible values for pingInterval
can be between 10 seconds and 2 hours,
depending on your infrastructure.
Implementation
factory Http2ClientTransport({
io.SecurityContext? context,
Duration? pingInterval,
Duration pingTimeout = const Duration(seconds: 15),
bool pingIdleConnections = false,
Duration idleConnectionTimeout = const Duration(minutes: 15),
}) {
return _Http2ClientTransport(
context,
_KeepAliveOptions(
pingTimeout: pingTimeout,
pingInterval: pingInterval,
pingIdleConnections: pingIdleConnections,
idleConnectionTimeout: idleConnectionTimeout,
),
);
}