pub struct BridgeConfig {
pub close: CloseFrame,
pub error_close: CloseFrame,
pub keepalive: Option<KeepAlive>,
pub control: Option<ControlReceiver>,
pub on_close: Option<CloseHook>,
pub on_ping: Option<ControlHook>,
pub on_pong: Option<ControlHook>,
}Expand description
Control-frame configuration and hooks for bridge_with /
serve_h2_with.
BridgeConfig::default enables server-initiated keepalive on by default
(KeepAlive::default: 30s ping / 15s timeout / 1001) so a silently-dead peer
can’t leak the bridge; wslay still auto-answers incoming pings, a Normal
Closure is sent on teardown, and no hooks fire. To opt out of keepalive, set
keepalive to None.
Fields§
§close: CloseFrameClose frame this side sends when it starts the close after the peer/upstream reached a clean EOF. Defaults to 1000 Normal Closure, empty reason.
error_close: CloseFrameClose frame this side sends when it tears down because the peer/upstream errored (a read/write failure — e.g. a reset — not a clean EOF). Defaults to 1011 (Internal Error); the proxy sets 1014 (Bad Gateway) so a failed upstream is distinguishable from a clean shutdown (à la nginx 502).
keepalive: Option<KeepAlive>Server-initiated keepalive (ping-and-timeout). Defaults to
Some(KeepAlive::default); set to None to opt out (and optionally
drive your own pings via control_channel instead).
control: Option<ControlReceiver>Receiver from control_channel, to send control frames while running.
on_close: Option<CloseHook>Called once when the connection ends, with the close frame describing why: the peer’s Close, the keepalive-timeout close, the teardown close, or 1006 (Abnormal) if the transport dropped without a Close.
on_ping: Option<ControlHook>Called when a Ping is received (wslay has already auto-queued the Pong).
on_pong: Option<ControlHook>Called when a Pong is received.