pub struct KeepAlive {
pub interval: Duration,
pub timeout: Duration,
pub close: CloseFrame,
}Expand description
Server-initiated keepalive: send a Ping when the connection goes idle, and disconnect the peer if it doesn’t respond in time.
This is the proactive half of ping/pong — wslay already auto-answers incoming pings, but never initiates its own. Browsers can’t send pings from JavaScript, so liveness for an h2ts client must be driven from the server; the browser’s platform auto-answers these pings transparently.
Fields§
§interval: DurationSend a Ping once the connection has been idle (no frame received) this long.
timeout: DurationIf no frame arrives within this long after that Ping, close the peer.
close: CloseFrameClose frame sent to the peer, and surfaced to BridgeConfig::on_close,
when keepalive fails. Defaults to 1001 (Going Away), “keepalive timeout”.
Implementations§
Trait Implementations§
Source§impl Default for KeepAlive
impl Default for KeepAlive
Source§fn default() -> Self
fn default() -> Self
Sensible server defaults: ping an idle connection every 30s and close it
(1001 Going Away) if no frame arrives within a further 15s. This is what
BridgeConfig::default (and thus bridge / serve_h2)
use — keepalive is on by default. Tune via KeepAlive::new, or set
BridgeConfig::keepalive to None to opt out.