Skip to main content

keep_alive

Function keep_alive 

Source
pub fn keep_alive<S>(
    stream: S,
    interval: Duration,
) -> impl Stream<Item = SseEvent>
where S: Stream<Item = SseEvent> + Send + 'static,
Expand description

Inject periodic comment frames (:keepalive\n\n) into an SSE stream.

Many HTTP proxies and load balancers close idle connections after 30-60s. This helper interleaves the original events with synthetic keep-alive comments emitted at interval. Comments are ignored by clients per the SSE spec.