Server never sends TransferOffer: media download is unimplemented end to end #127
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage#127
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while running the end-to-end smoke test for #115, on dev tip
c789d2b(after #126, the reconnect-token fix, had already landed).Symptom
Server, panel and client all come up clean. The client enrolls, gets approved, reconnects as
Accepted, receives the playlist (sync: server says Accepted: welcome backthen no further sync errors). Playback then loops forever on:Player::next(crates/client/src/player.rs) only prints that line forFallbackReason::CannotLoad— meaning the playlist was received and an item is due, butcached(hash)never returns a path. No download ever starts: nothing in the client log mentions a transfer, an offer, or an error (success is silent by design, but so is "never attempted").Root cause
The server never sends a
TransferOffer.grep -rn TransferOffer crates/server/srcis empty — the whole server-side push half of media transfer does not exist.crates/server/src/ws.rs:5documents this directly: "Transfers are later work. A device that reachesAdmission::Registeredhere registers its sender inDeviceConnectionsand is kept open on a heartbeat, forwarding whateverassign_playlist... pushes to it until it disconnects."push_to_deviceincrates/server/src/playlists/handlers.rs:326-351builds and pushesMediaManifestandPlaylistPushonly. It never walks the manifest and sends oneTransferOfferper file, asplan/shared/protocol.mdspecifies.plan/shared/protocol.md:248— "the server sendsMediaManifest,PlaylistPushand oneTransferOfferper file the playlist needs" — and the## Media transfersection (line 270 on) gives the full offer/accept/chunk/complete frame contract.crates/client/src/session.rs(on_offer,on_binary, chunked resume, hash verification) andcrates/client/src/cache.rs. It has never been exercised against a real server because nothing on the server side ever offers a transfer.So this is not a race or a timing bug: the server has no code path that constructs a
ServerControl::TransferOfferat all, for any device, ever.Impact
This is the core MVP feature — "the device downloads and plays the assigned content" — and it does not work end-to-end. A device can enroll, get approved, and receive a playlist description, but it can never actually render an image or video it does not already have cached, because it is never sent the bytes. This blocks #115's step 5 and will block #29 (the product owner's test week on a real mini PC) the same way.
What's needed
Server-side logic that, per connected device and per playlist assignment (and really per manifest entry already being pushed in
push_to_device), opens a transfer: picks atransfer_id, sendsTransferOffer { transfer_id, sha256, total_bytes }for each manifest entry, and onTransferAcceptstreams the file (from wherever uploaded media is stored, e.g. the media directory logged at startup) asMAX_CHUNK_BYTES(256 KiB) binary chunks with the 12-byte header, honoringresume_from_offset, interleaved with control frames per the spec.DeviceConnections(crates/server/src/connections.rs) already has the per-device outbound channel; this needs its own task per transfer (or per device) and bandwidth/concurrency limits per the spec's table ("Concurrent transfers and total bandwidth are limited, server-side").This is a design-and-implementation task for the back-end engineer, not a test-writer fix — filing per GRI-1885's Done-when criteria ("every bug found is a separate forge issue in the MVP milestone").
Implemented server-side media transfer end to end:
push_to_device(playlists/handlers.rs) now sends oneTransferOfferperMediaManifestentry, afterMediaManifest/PlaylistPush, matchingplan/shared/protocol.md.DeviceConnectionsgrew a per-connectiontransfer_idallocator (resets on reconnect, per spec: "it means nothing on the next connection").ws.rs::run_sessionnow parses incoming client text frames (TransferAccept/TransferComplete/Heartbeat), tracks offered files, and spawns a streaming task on accept that reads<media_dir>/<sha256>fromresume_from_offset, chunks atMAX_CHUNK_BYTES, and hands frames back over an internal channel so the socket keeps one writer.crate::transfers::TransferLimiter: a semaphore for concurrent transfers and a token-bucket bandwidth limiter, both shared server-wide, per the spec's "Concurrent transfers and total bandwidth are limited, server-side". Configurable via a new[transfers]config section (max_concurrent, default 8;max_bandwidth_bytes_per_second, default 0/unlimited), documented inplan/server/configuration.md.Note on process: there was no QA-written test for this issue — it's the design-and-implementation gap itself. Given the protocol is frozen/spec'd byte-for-byte and the client side already has full tests defining the exact wire contract, I implemented against that spec/client as the oracle and wrote my own unit + integration tests.
Verification:
cargo clippy -p server --all-targets -- -D warnings: clean.cargo test -p server --lib: 126 passed, 1 ignored (pre-existing, needs poppler-utils).cargo test -p server --test ws_integration --test enrolment_acceptance_integration --test playlist_integration --test playlist_acceptance_integration: 29 passed, including two new end-to-end tests that round-trip a real file through offer→accept→chunks→complete and verify the received bytes hash to the offered sha256.scripts/local-gates.shrunning now; will follow up with the result before opening the PR.Branch:
fix/GRI-1916-server-media-transfer.