Repository navigation
Description
Summary
Make Silo's direct-stream resumption contract explicit and observable so first-party clients can safely discard/reopen progressive HTTP responses instead of requiring long reverse-proxy timeouts.
The server already has the important foundations: byte-range delivery through http.ServeContent and a rolling 180-second no-progress write deadline. This issue adds entity validation, capability negotiation, and operational visibility around that behavior.
Context
Progressive clients commonly download faster than playback, fill their local buffer, and stop reading. A reverse proxy with nginx's default client-facing send_timeout 60s can terminate the response while the player drains its buffer. Clients should recover by issuing a new Range request at the exact byte cursor, without remounting the player.
A server-only heartbeat cannot solve this: once the client's receive window is full, the proxy cannot forward payload bytes, and injecting out-of-band bytes would corrupt the media response. Server byte pacing also fails during a user pause and keeps a connection occupied for the entire title.
Current implementation
Source baseline reviewed: 34573823242905ae38677c61ea49d96198a09794.
internal/playback/directplay.gowraps the response inhttpstream.NewRollingDeadlineWriterand serves the file withhttp.ServeContent, providing standard byte-range and conditional-request behavior.internal/httpstream/rolling_deadline.gouses a 180-second rolling stall window, configurable throughSILO_STREAM_WRITE_STALL_TIMEOUT.- A write-deadline reap is currently difficult to distinguish operationally from an ordinary client disconnect.
- Progressive remux is chunked ffmpeg output and is not byte-resumable like original-file direct play.
- Protocol v3 already has additive playback capability features suitable for advertising a stronger resume contract.
Proposed PR scope
- Define and advertise a capability such as
direct_stream_resume_v1for original-file direct play. The contract should state:Accept-Ranges: bytes;- correct 206/
Content-Rangebehavior; - stable entity validation for the lifetime of the playback plan;
- safe repeated idempotent GET/HEAD requests;
- clear 416 behavior at/past EOF.
- Emit a stable
ETagfor direct-play files and supportIf-Rangecorrectly:- unchanged entity → ranged 206;
- changed/replaced entity → full 200 or explicit replan path, never a silently stitched mixed file.
- Preserve
Last-Modified,Content-Length, HEAD, and existing authorization/session ownership behavior. - Add observability that distinguishes:
- rolling-deadline/no-write-progress reap;
- client cancellation/reset;
- completed response;
- range resume request and starting offset.
- Add counters suitable for dashboards/alerts: active direct-stream transports, stalled-write reaps, ranged resumes, invalid ranges, and bytes requested/sent where practical.
- Document that progressive remux is not covered by the resume capability. Prefer segmented HLS/copy-codec HLS for remux as separate follow-up work.
- Keep the existing 180-second origin stall bound initially; lowering it is a separate rollout decision after client hardening.
Acceptance criteria
- Direct-play responses include a deterministic validator and range headers.
- Matching
If-Rangeresumes at the requested byte with 206 and correctContent-Range. - A mismatched validator cannot combine bytes from different file revisions.
- A stalled write is reaped within the configured rolling deadline and recorded distinctly from a normal disconnect.
- Multiple sequential ranged requests for one playback session do not incorrectly expire or invalidate that session.
- Legacy clients continue to work without sending
If-Rangeor probing the new capability. - Progressive remux is never falsely advertised as byte-resumable.
Verification
- Unit/integration tests for GET, HEAD, open-ended/suffix ranges, matching and mismatching
If-Range, invalid ranges, 416 at EOF, and file replacement between requests. - A deterministic stalled-writer test that asserts timeout classification/metrics.
- A playback-session lifecycle test covering close-while-paused followed by a ranged resume after a delay.
- End-to-end test through nginx/OpenResty with a short client-facing
send_timeout, confirming a hardened client resumes without creating a new playback plan.
Non-goals
- Payload heartbeat bytes.
- Server-side playback-rate pacing.
- Making progressive ffmpeg remux output byte-resumable in this PR.
- Replacing all original-file direct play with HLS.
Activity
Quick104 commentedon Jul 21, 2026
Coordinated work:
feat(playback): formalize resumable direct streams and stall observab…
Quick104 commentedon Oct 23, 2026
Fixed on
mainby #464 and #594. They add ETag/If-Range resume, stalled-write classification and metrics, If-Match outcomes, and thedirect_stream_resume_v1capability. The Apple and Android work has merged too.