Skip to main content

read_subscription_request

Function read_subscription_request 

Source
pub async fn read_subscription_request(
    socket: &mut WebSocket,
) -> Result<Option<SubscriptionRequest>, ServerError>
Expand description

Read the first subscription frame from an accepted WebSocket.

Ping/pong frames are ignored while waiting. A malformed frame or a socket error is a decode failure the caller reports as one terminal error frame.

A clean close before any subscribe frame arrives — either an explicit Close frame or the stream ending (recv returns None) — is NOT an error: it is the normal lifecycle of a client that disconnects before subscribing (e.g. a React StrictMode double-mount whose first socket is torn down before it can send, or a page navigated away during the handshake). It is returned as Ok(None) so the caller ends the connection gracefully without logging a spurious warning or trying to write an error frame to an already-closing socket.

§Errors

Returns ServerError::Wire (invalid_input) only when the request frame is present but cannot be read or decoded.