An embedsports stream's session expires when it is not polled, so a restart drops the game #136
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
cmoriarty/sports-breaker#136
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?
Streams read from the embedsports.me player (s2watch.cyou, suksukstreams.cfd; PR #133) are tied to a session that the stream server ends when nobody polls the playlist for a while.
Seen 2026-11-10
A scratch test the same night had the playlist still answering re-checks 100 s after the page was closed, but there the re-checks themselves were polling it.
To find out
Ideas
Done when a restart, and three idle minutes, no longer cost a game on this player its Ready state.
Not fixed: no embedsports stream was live while the batch was built (04:45 to 05:15Z; the late games' s2watch and suksukstreams links used other players), so nothing could be measured.
More evidence from the evening (production events, 01:27 to 03:14Z)
.../1794279842/...,ssid=sv2.1794279849...), so the 401s are not that expiry.Two explanations, neither tested
To settle it, with an embedsports game live (men's college basketball evenings), run from the repository root:
CLOUDFLARE_SOLVER_URL=http://192.168.1.115:8191 DATA_DIR=<a scratch folder> PYTHONPATH=backend backend/.venv/bin/python session_two.py 90 480It polls one session like a channel, opens a second on the same stream after 90 s, and reports which is refused, when, and whether the first address (
play.m3u8) gives a fresh playlist afterwards. The script is in the session's scratch folder and is pasted below in the next comment if it is wanted in the repo.Likely fix either way: when the playlist answers 401, ask the link's first address again for a fresh one and play on (the renewal path of #73), before any swap. That needs the measurement first.
session_two.py, the probe named above:More evidence, 2026-11-14 (production on
3a94153; from the game's events and a recorder that read/api/channelsevery 2 s from 18:08Z to 18:48Z)Penn vs. Harvard, a background channel nobody watched, on this stream through s2watch.cyou and suksukstreams.cfd:
What it adds:
Each end closes the background channel, and it comes back one to two minutes later when a check finds the stream again. A viewer on this game would have had a failure about every ten minutes.
Cause found, 2026-11-14. Measured on production (
3a94153) with a recorder on/api/channelsand the readiness file, the container log, and probes and page traces run from a second address.What ends the session
The embedsports player's page is given a session of ten minutes, and the page keeps it alive. The app never did.
seckyes.cc, for a session. The answer saysvalid_until(ten minutes on) andrefresh_after: 300.#EXT-X-KEY … URI="https://seckyes.cc/<id>/<uuid>?…&exp=<valid_until>". At that second the stream hosts answer 401 with the headerx-seckey-reason: expiredto the playlist, to segments already listed and to the link's first address (play.m3u8).r=1. Each answer moves the end ten minutes on. The site's own player played past ten minutes that way in three traces.Evidence
Production, the playing link of each channel on this player between 20:11Z and 21:14Z. The issue time is the stamp in the link's first address (
ssid=sv2.<stamp>) less two hours; the refusal is the second the channel's first reload failed.exp20:34:47Z): a playlist polled every 2 s was refused at 20:34:47Z. A second playlist from the same first address, polled five times in ten minutes, was refused in the same poll. The first address asked again was refused too.What it is not
ssid=sv2.<stamp>): that one is two hours ahead, as comment 8134 said. It is when the page's token expires.The app can send the renewal
Sent with the app's own client and the page closed, the renewal was accepted (HTTP 200,
valid_untilten minutes on), twice, and the playlist was still answering 736 s after the page read, 138 s past its first end (20:43Z to 20:55Z). Every value it carries is handed out by the key service's last answer.What each end cost
background.sync.The change (OpenSpec
sessions-kept-alive; written in a work tree, not committed)resolver/seckey.py,keepalive.py;LINK_KEEPALIVE_ENABLED=0turns it off). Such a link is read again only when the key service says it must be, about two hours on.Checked against live streams, from a second address (not production)
valid_until(printed for the first two).openspec validate sessions-kept-alive --strictvalid;make test1367 passed, 1 skipped;npm --prefix frontend test265 passed;make e2epassed.Not known
reauthorize_at(115 minutes after the page read). The app reads the page again five minutes before it. A probe is running past that mark tonight.link.sessionin/api/channels, and one "kept alive" line per link in the log).The details and the file formats are in
docs/stream-sources.md(section 2026-11-14) of the change.Addendum, 2026-11-14 23:40Z: the runs that were still going. All from the second address, not production. Nothing is committed or deployed.
What the key service answers after
reauthorize_at(was "not known")One session, renewed every five minutes by the app's client with the page closed, until it was refused (Missouri vs. Georgia on my1click.top, page read 21:16:32Z):
refresh_after: 300reauthorize_atvalid_until23:21:40Z,refresh_after: 289(the second ofcsrf_expires_at)x-seckey-reason: reauthorization_requiredexpiredvalid_until: 403reauthorize_at, at 110 minutes. That is 15 minutes before the end, with two more renewals still to be accepted, so nothing in the change had to move.The two runs of the change's own code, finished
Still not known
link.sessionin/api/channels, and one "kept alive" line per link in the log.Merged and deployed, 2026-11-15.
c4962b8(pull request #166, commit9a8b5e1) at 00:22:48Z, on the owner's word./api/versionreportsc4962b8.Seen live, 00:24Z to 00:59Z (read only:
/api/channels,/api/eventsand the container log)Seen once, cause not established
Not done
sessions-kept-aliveis not archived.Archived, and the restart case seen live, 2026-11-15.
27df2a8onmain(openspec/changes/archive/2026-11-14-sessions-kept-alive), on the owner's word. The image job succeeded, and the app restarted at 01:37:01Z and was up 3 s later. Nobody was watching.