Skip to content

Session resumption

Resumption preserves session identity and server-side session state across a transport loss.

Preserved: session ID, authenticated principal, granted capabilities, group memberships, channel subscriptions, datagram key-to-name bindings (not datagram seq counters, §11.3), and all sequenced frames not yet acknowledged. Not preserved: call streams. Every call in progress at transport loss is terminated: the caller’s library completes it locally with UNAVAILABLE, and the callee’s handler is cancelled. Clients MAY retry calls marked idempotent in the contract (§12.2), on the resumed session or on a new one.

Sequenced frames: every frame on the control stream and on lane streams except HELLO, WELCOME, REJECT, PING, PONG, ACK, GOAWAY, CLOSE, LANE_OPEN and DATAGRAM. That is: NOTIFY, AUTH_REFRESH, AUTH_RESULT, AUTH_EXPIRING, REQUEST_ERROR, SUBSCRIBE, SUBSCRIBED, UNSUBSCRIBE, UNSUBSCRIBED, PUBLICATION, PRESENCE and DGRAM_BIND, in both directions. (Client control requests must be sequenced too; otherwise a SUBSCRIBE lost in a transport drop leaves the client waiting forever, and DGRAM_BIND state could be “preserved” without ever having arrived.) LANE_OPEN only maps a stream to a lane on the current transport (§9.2).

When resume is granted, each sequenced frame MUST carry seq (key 12), assigned when the frame is first written to a transport: frames waiting in the outbound queue (§13.5) or buffered while detached have no seq yet and get one when they are sent or replayed. Counters are per lane, per direction: lane 0 (the control stream) and each lane stream have their own counter starting at 1 and incrementing by 1 per sequenced frame written. Per-lane counters are required because on WebTransport lanes are delivered independently, so a single counter across lanes could never be acknowledged contiguously.

Receiving: a receiver processes a sequenced frame whose seq is one more than its receive position on the lane and discards one whose seq it has already processed. A sequenced frame without seq is a PROTOCOL_ERROR, and so is one with any other seq, except on a lane listed in lost (below).

Acknowledgment:

  • Each peer acknowledges with an ack map (key 44): lane → highest seq n such that all frames 1..n on that lane have been received. It is sent either as an ACK frame on stream 0 or piggybacked as key 44 on any sequenced frame the peer is sending anyway (receivers MUST accept both forms). Lanes omitted from the map are unchanged.
  • A peer SHOULD acknowledge at least every 1 s while it has unacknowledged receipts, or after every 64 sequenced frames, whichever comes first.
  • Senders keep sequenced frames in a replay buffer until acknowledged: frames sent and not yet acknowledged and, while the session is detached, frames not yet sent (including those still queued for writing when the transport was lost). The buffer is bounded (default 1 MiB per session per direction).
  • Buffer pressure: a sequenced send never blocks and the bound is never exceeded. When a frame would not fit, the sender evicts buffered frames in this order until it does: (1) PUBLICATION frames for channels with history, oldest first; the sender drops that subscription and queues one UNSUBSCRIBED {code: 2} (§10.3) for the channel in their place, so the client re-syncs from history with since. (2) PRESENCE frames, oldest first; the sender drops that subscription and queues one UNSUBSCRIBED {code: 2} for the channel as in (1), so the client resubscribes and receives a fresh snapshot. (3) Any other sequenced frame, oldest first. These frames are never evicted: control requests (AUTH_REFRESH, SUBSCRIBE, UNSUBSCRIBE), their replies (SUBSCRIBED, REQUEST_ERROR, AUTH_RESULT, and an UNSUBSCRIBED that answers an UNSUBSCRIBE), DGRAM_BIND in both directions, and the replacement UNSUBSCRIBED frames. Evicting a reply would leave a rid without an answer, and evicting a DGRAM_BIND would leave a key unbound for the rest of the session, because keys are never rebound (§11.2). A replacement UNSUBSCRIBED is added only after enough bytes have been freed for it.
  • A recoverable eviction (steps 1 and 2) of a frame that was never sent leaves no gap: no seq was assigned, and the resubscribe covers the lost data. If such a frame had been sent and is unacknowledged, its lane records a gap. Every eviction in step 3, sent or unsent, records a gap on the frame’s lane, so the application learns of a dropped notification even when it was buffered while detached.
  • A sequenced frame that does not fit after every evictable frame is gone, including one larger than an empty replay buffer, is rejected locally with RESOURCE_EXHAUSTED and never sent. This applies to the never-evicted frames too. For a control request the rejection precedes any send, so no rid is left without a reply.
  • Gaps: the resuming WELCOME carries lost (key 53), the lanes on which a gap was recorded for frames toward the client; the client’s resume map carries lost for the other direction. On each listed lane, for the rest of the new transport, the receiver accepts a frame whose seq is greater than its receive position even when it is not contiguous, and sets its receive position to that seq (on a lane where no seq was skipped this changes nothing). Client libraries surface a gap event per listed lane; applications decide what a missed notification means for them.

Resuming:

  1. The client detects transport loss (error, close without CLOSE, or idle timeout).
  2. It opens a new transport (any binding, §4.4) and sends HELLO with resume {13: token, 19: session_id, 44: ack_map, 53: lost?}, where ack_map is the client’s per-lane receive position and lost lists the lanes on which the client recorded a gap. The HELLO MUST offer the same protocol version and codec as the original session (the replay buffer is already encoded) and MUST request at least the capabilities granted to the original session; the server MUST REJECT RESUME_FAILED otherwise. The client SHOULD append the session ID to the endpoint URL as the query parameter session (for example wss://host/rt?session=s_7Qm2) so that load balancers can route the resume to the node that holds the session; the session ID is public (§7.2) and this does not relax the rule that credentials never appear in the URL (§4.1). Servers ignore the parameter otherwise. For WebTransport this requires a balancer that terminates HTTP/3; layer-4 QUIC balancers cannot see the parameter, and the resume falls back to takeover (§13.8).
  3. If the session exists, is within resume_window (default 30 s), the principal matches and its credential is valid (§7.5), the server replies WELCOME with the same session ID, a new resume token, the same granted capabilities, resumed: true, and ack = its per-lane receive position for frames from the client.
  4. Both peers retransmit, per lane and in original order with original seq values, every buffered frame with seq greater than the peer’s acknowledged value for that lane, followed by buffered frames that were never sent, which get their seq as they are written. Lane streams are reopened on the new transport with LANE_OPEN, which is not sequenced, before the lane’s buffered frames are replayed. A resuming client MAY replay from its last known acknowledgment before WELCOME arrives, within the pipelining budget of §4.1; the server discards duplicates. Receivers discard any frame whose seq they have already processed; on a lane listed in lost they re-anchor as described above.
  5. The server re-evaluates authorization (§7.5). Normal operation continues.

If the session is unknown or expired, the principal differs, the credential expired and HELLO carries no fresh auth (§7.5), the codec or version differs, or the requested capabilities do not include the original grant: REJECT RESUME_FAILED. A server that does not grant resume answers a HELLO carrying resume with REJECT RESUME_FAILED (the session is unknown to it); this is not a capability violation (§7.10).

Server behavior while detached: notifications and channel frames targeted at the session are appended to the replay buffer without seq, evicting under pressure as described above; datagrams are dropped (§13.1). The session still counts toward its groups and channel subscriptions. Server-initiated calls to a detached session fail locally with UNAVAILABLE and nx: true (there is no transport to carry them; callers may retry after the session resumes, §8.8). On resume_window expiry the session ends: groups are left, subscriptions dropped, presence leave events emitted.

Limits: servers MUST cap detached sessions per principal (default 8) and in total (default 10,000); both caps apply per node. Anonymous sessions are grouped by source address for the per-principal cap. When a cap is exceeded, the oldest detached session ends early. Resume attempts are rate-limited per source address like handshakes (§14).

Resume token security: single-use (rotated on every WELCOME), bound to the principal, never logged, and compared in constant time. A token is spent only by a successful resume; a failed attempt changes no server state except rate-limit counters.


From the specification: §7.8.