From ec9c1fa96a03e819ede3ba0ee6d119f950f78bf3 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 13 Nov 2026 15:42:18 -0800 Subject: [PATCH 1/2] fix(interop): the refused WebSocket session expects a redial, as #8618 specifies The relay refuses a URL token after ALPN already established the session, so since #8618 the reconnecting handle redials it like any other close. The check still waited for the handle to stop on its own under an unlimited window. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/reconnect.rs | 3 +-- test/interop/README.md | 5 +++-- test/interop/clients/js/close.ts | 3 ++- test/interop/clients/js/src/close.ts | 23 +++++++++++++++++++---- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/rs/moq-net/src/reconnect.rs b/rs/moq-net/src/reconnect.rs index 4a4512d3e1..25b1b9da8c 100644 --- a/rs/moq-net/src/reconnect.rs +++ b/rs/moq-net/src/reconnect.rs @@ -10,8 +10,7 @@ //! //! The first walk of the peer's addresses fails fast: if no address establishes a //! session, the policy ends with [`Action::Done`] carrying that walk's error rather than -//! retrying, so a setup mistake surfaces at once instead of looping. The one exception is -//! a refused credential the tokens have replaced since, which earns another dial. A client started +//! retrying, so a setup mistake surfaces at once instead of looping. A client started //! before its peer is reachable therefore exits, for its supervisor or app to restart. //! Once a session has been established, a later failure backs off and retries under //! [`Backoff`], so restarts and redeploys still recover. diff --git a/test/interop/README.md b/test/interop/README.md index 3ae366abdf..19f6c9df2f 100644 --- a/test/interop/README.md +++ b/test/interop/README.md @@ -137,8 +137,9 @@ released relays and clients, skip it. Whenever the browser subscriber is in the run, the matrix ends with a close-code case: Chromium dials the relay with a token its public rules refuse, and `WebTransport.closed` must carry the relay's code and reason. A WebSocket-only -`Connection` must publish the same Unauthorized session error and stop its -unlimited reconnect loop. Chromium treats a +`Connection` counts the refused session as connected, so it must redial it +like any other close and, once a short retry window runs out, publish the same +session error. Chromium treats a server's HTTP/3 control stream ending as fatal, so a server that ends it under the close capsule loses both; no Rust peer is that strict. diff --git a/test/interop/clients/js/close.ts b/test/interop/clients/js/close.ts index 3f080349cf..362e05c38d 100644 --- a/test/interop/clients/js/close.ts +++ b/test/interop/clients/js/close.ts @@ -1,7 +1,8 @@ /** * Proves a relay's rejection reaches the page over WebTransport and WebSocket. * WebTransport.closed has to carry the relay's code; a WebSocket Connection has - * to publish its MalformedAuthToken session error and stop reconnecting. + * to redial the refused session within its retry window, then publish its MalformedAuthToken + * session error. * * Chromium treats the server's HTTP/3 control stream ending as fatal, so a server that ends it * alongside the CLOSE_WEBTRANSPORT_SESSION capsule turns the close into a bare connection error. diff --git a/test/interop/clients/js/src/close.ts b/test/interop/clients/js/src/close.ts index 83205e0e21..7140ffad76 100644 --- a/test/interop/clients/js/src/close.ts +++ b/test/interop/clients/js/src/close.ts @@ -9,6 +9,7 @@ * * @module */ +import { Duration } from "@moq/clock"; import { Connection, Error as MoqError } from "@moq/net"; import type { CloseState } from "./contract"; @@ -41,20 +42,34 @@ export async function refused(relay: string): Promise { return closed; } -/** A WebSocket refusal reaches the reconnecting handle as a terminal session error. */ +/** + * A WebSocket refusal reaches the reconnecting handle as its session error. + * + * The relay closes a session that ALPN already established, so the handle redials it like any + * other close until its retry window runs out, then publishes the last close. + */ export async function refusedWebSocket(relay: string): Promise { const url = new URL(relay); url.protocol = "ws:"; url.searchParams.set("jwt", "refused"); - const connection = new Connection({ url, share: false }); + const connection = new Connection({ + url, + share: false, + delay: { initial: Duration.millis(200), max: Duration.millis(200), timeout: Duration.secs(2) }, + }); + // Every refused session counted as connected first; a second one proves the handle redialed. + let connected = 0; + const dispose = connection.status.subscribe((status) => { + if (status === "connected") connected++; + }); try { - // The default retry window is unlimited. An error is published only once - // Reload stops this URL, so observing it proves the rejection is terminal. let error = connection.error.peek(); while (!error) error = await connection.error.changed(); + if (connected < 2) return { error: `gave up after ${connected} session(s) instead of redialing: ${error}` }; if (!(error instanceof MoqError.Session)) return { error: String(error) }; return { closeCode: error.code, reason: error.message }; } finally { + dispose(); connection.close(); } } From ea58614da2112c6443e8b12f15053cf60af0697a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 13 Nov 2026 19:32:40 -0800 Subject: [PATCH 2/2] docs: drop the refused-credential redial the policy never had walk_failed ends the policy on any failure before the first session, so the Backoff and with_tokens docs no longer promise a redial when the tokens change, and interop.sh describes the WebSocket redial. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/reconnect.rs | 6 ++---- test/interop/interop.sh | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/rs/moq-net/src/reconnect.rs b/rs/moq-net/src/reconnect.rs index 25b1b9da8c..9a268ef6a9 100644 --- a/rs/moq-net/src/reconnect.rs +++ b/rs/moq-net/src/reconnect.rs @@ -54,8 +54,7 @@ const PROBE_MAX: Duration = Duration::from_secs(300); /// When to redial after a failure, and when to give up, once a session has been established. /// -/// Before then nothing retries: the first walk ending without a session ends the policy, -/// unless the peer refused credentials the tokens have replaced since. +/// Before then nothing retries: the first walk ending without a session ends the policy. /// /// `initial` and `multiplier` set the wait before each retry, `max` caps it, and /// `healthy` decides which sessions count as failed attempts. The delays carry jitter, @@ -507,8 +506,7 @@ impl + From> Reco /// Present `tokens` on every dial, through [`Attempt::client`]. /// - /// A refused credential then earns another dial once the tokens change, and an ended - /// tokens handle ends the policy at its next walk. + /// An ended tokens handle ends the policy at its next walk. pub fn with_tokens(mut self, tokens: auth::Tokens) -> Self { self.tokens = Some(tokens); self diff --git a/test/interop/interop.sh b/test/interop/interop.sh index 0044b1877e..85d842df82 100755 --- a/test/interop/interop.sh +++ b/test/interop/interop.sh @@ -2312,7 +2312,8 @@ run_matrix() { done # The relay refuses a token that is not a JWT, and Chromium has to read the close code and - # reason it sends. WebSocket must surface MalformedAuthToken and stop reconnecting too. + # reason it sends. WebSocket must redial the refused session within its retry window, then + # surface MalformedAuthToken. # Chromium is the strict peer here, so no Rust client stands in for it. The relay refuses # before any version is negotiated, so one pass covers it. if [[ "$VERSION" == auto ]] && needs js; then