Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/bin/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ none and are closed the same way. A second
signal exits immediately; `--drain-timeout 0s` closes sessions immediately.
Pending handshakes and admission requests share the same drain window, and an
open stdin pipe does not keep the process alive afterward. Admission is part of
the handshake, so `--listen-timeout` bounds it too; `0s` leaves admission without
the handshake, so `--listen-timeout` (default `30s`) bounds it too; `0s` leaves admission without
a deadline.

`moq import --help` lists the sources and `moq import rtmp --help` a specific
Expand Down
2 changes: 1 addition & 1 deletion doc/bin/relay/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Precedence is CLI, then env, then file, then defaults.
[listen]
bind = "[::]:443" # QUIC (UDP), as --listen. Omit for a stream-only relay.
version = ["moq-lite-05"] # Restrict accepted versions. Omit for all but moq-lite-07-wip.
timeout = "10s" # Handshake deadline. "0" waits forever.
timeout = "30s" # Handshake deadline. "0" waits forever.

[listen.reset]
secret = "/etc/moq/reset.key" # File holding 64 hex chars. Omit for a random key.
Expand Down
2 changes: 1 addition & 1 deletion doc/lib/rs/moq-net.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ What you use it for, beyond what the concept page already describes:
- **End content by finishing tracks.** A broadcast has no finished state. When the input ends, finish each track: `finish(self)` consumes the producer and returns a `track::Finished`, which can still take an older group below the end, be read, or be aborted, but not append. Hold it, and the broadcast stays announced and keeps serving the track until you close it or drop its route; dropping the last handle releases the track, so new readers no longer find it. How long to keep it up for late readers is yours to decide: `moq_mux::Linger` holds a hang broadcast for a fixed window. Ending a group returns a `group::Finished`, which can be read or aborted to release its cache: `finish(end)` ends it whole where its content stops, so a reader can tell the group starting there continues it, and `close()` ends it without one.
- **Demand says whether anyone is watching.** `demand()` on a track, group, or broadcast says whether a subscriber is attached. First-party capture does not wait for it: video encodes while enabled and audio keeps raw PCM to encode when someone listens, so a late subscription's `delay.max` or a FETCH finds the recent past. Demand gates bandwidth reservations, transcode rungs, and on-demand video where a publisher opts in, which saves the encode but leaves nothing from before the first subscriber. Holding a broadcast or track consumer is not demand: a track consumer requests nothing until it queries, subscribes, or fetches, and those count until dropped. A shared fetch stays up until its last reader leaves. Demand rolls up: a frame being read keeps its group wanted, a group a subscription or fetch handed out keeps its track wanted until read to its end, and any wanted track keeps its broadcast wanted.
- **Use the model without a runtime.** By default `moq-net` is its `poll_*` APIs and origin driver with caller-supplied time. The `async` feature adds their async wrappers, `time::run`, and both wire sessions.
- **You drive the session, or `moq-tokio` does.** `connect` and `accept` return a session plus a driver that never reads the clock itself. `moq_net::time::run` polls it on tokio. `moq-tokio` hides that. A custom transport implements `moq_net::transport::poll`, and `moq_net::transport::memory::pair` links two sessions in one process with no sockets, for tests or in-process links. `Server` bounds each accept with one deadline (10 s by default, `with_timeout`) across SETUP, your admission decision (`Handshake::expired`), and moq-lite 01/02's SETUP reply, and opens a receive window the transport held back once you admit (`with_receive_window`).
- **You drive the session, or `moq-tokio` does.** `connect` and `accept` return a session plus a driver that never reads the clock itself. `moq_net::time::run` polls it on tokio. `moq-tokio` hides that. A custom transport implements `moq_net::transport::poll`, and `moq_net::transport::memory::pair` links two sessions in one process with no sockets, for tests or in-process links. `Server` bounds each accept with one deadline from the connection's arrival (30 s by default, `with_timeout`), across your transport handshake (`Server::deadline`), SETUP, your admission decision (`Handshake::expired`), and moq-lite 01/02's SETUP reply, and opens a receive window the transport held back once you admit (`with_receive_window`).
- **Reconnect policy comes with it.** With the `async` feature, `moq_net::Reconnect` decides which of a peer's addresses to dial, how long each dial and handshake may take, when to back off and give up, and how to follow a GOAWAY, without doing I/O: you dial each `Attempt` it asks for and report back. `moq-tokio`'s `Connection` runs it, so a client on another runtime gets the same policy rather than a copy. The first walk of the peer's addresses fails fast: if it yields no session, the policy ends with that walk's error instead of retrying, so a setup mistake such as an untrusted certificate or no version in common surfaces at once, and a client started before its relay is reachable exits for its supervisor to restart. Once a session has been established, later failures back off and retry, so relay restarts still recover.
- **A session bounds what its peer can hold.** Each request holds a stream, so the transport's stream credit bounds subscriptions and FETCHes. Once that credit runs out, a waiting open resets the lowest-priority group stream below it, which the subscriber sees dropped, so the credit it frees goes to the higher-priority group. `session::Limits` (via `Client::with_limits` and `Server::with_limits`) bounds the announcements per session. The default suits a relay mesh, so lower it for untrusted peers. Past it, the session closes with `TOO_MANY_REQUESTS`. Peer-declared lengths are capped before they are buffered.
- **Authorization is in band.** On moq-lite 07 (`moq-lite-07-wip`, opt-in), `session.auth()` presents tokens without reconnecting and watches the grant the peer sent back. `add(token)` presents another and returns its `Credential` at once, and `credential.answered().await` waits for the peer to take it: on its AUTH stream, or at once on moq-transport without AUTH, where only a request that names it carries it. Dropping its last clone, including any a route holds, withdraws it, answered or not. A handle passed to `Client::with_auth` outlives each session, so its tokens, and the routes naming them, carry across your own reconnects. A server verifies tokens itself by taking `handshake.requests()` before `ok()`. `authorize(&grant)` narrows or widens a live session on any version: what falls outside resets with `Unauthorized` and the session stays up. A client that publishes outside its grant closes the session, naming the path.
Expand Down
38 changes: 0 additions & 38 deletions quest/m1/relay-accept-deadline.md

This file was deleted.

7 changes: 4 additions & 3 deletions rs/moq-net/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ impl Drop for Admitted {
}
}

/// How long [`Server`] gives a connection to be accepted, from its arrival through the SETUP
/// reply, unless [`Server::with_timeout`] says otherwise.
pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10);
/// How long [`Server`] gives a connection to be accepted, from its arrival through admission,
/// unless [`Server::with_timeout`] says otherwise. Matches a client's connect timeout, so a
/// client whose handshake probes back off under heavy loss is not shed first.
pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(30);

/// A MoQ server session builder.
#[derive(Clone)]
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-tokio/src/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub struct Config {
/// Maximum time for one accepted connection to finish its handshake: the
/// QUIC, WebTransport, WebSocket, or qmux one, then the MoQ SETUP, whatever the
/// server runs under (admission, say), until the session is accepted. Defaults to
/// 10 seconds; set to 0 to wait forever.
/// 30 seconds; set to 0 to wait forever.
///
/// A peer that connects and then never speaks would otherwise hold its
/// connection open indefinitely, since keep-alives count as activity. The
Expand Down
12 changes: 10 additions & 2 deletions rs/moq-tokio/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,8 +1326,16 @@ mod timeout_tests {
let _stream = kio::wait(|waiter| peer.poll_open_bi(waiter, Default::default()))
.await
.unwrap();
tokio::time::advance(timeout.unwrap_or(crate::listen::DEFAULT_TIMEOUT)).await;
let result = accept.as_mut().now_or_never();
// Step a second at a time so QMux keep-alives flow as on a live link: one jump
// past their 30s deadline would close the session without a ping.
let mut result = None;
for _ in 0..timeout.unwrap_or(crate::listen::DEFAULT_TIMEOUT).as_secs() {
tokio::time::advance(time::Duration::from_secs(1)).await;
result = accept.as_mut().now_or_never();
if result.is_some() {
break;
}
}
if expires {
assert!(
matches!(result, Some(Err(crate::Error::MoqNet(moq_net::Error::Timeout)))),
Expand Down