Relay a stream
Use this guide to publish a stream you don't produce, for example a radio station's public .m3u8, as a channel.
Nothing of yours ingests or transcodes it: one of your organization's relay nodes pulls the stream from the source
and serves it, unchanged, under an address of its own. The channel is otherwise an ordinary channel: it joins channel
groups, is published and pushed to devices like any other. For the fields, see the
Playback API.
Before you begin¶
- Your role in the workspace has
workspace:channels:manage. - An organization admin has set up a relay node and marked it Use for external relays (or the organization has
only one such node). Without it, creation fails with
400. - The source is an
http(s)URL of an.m3u8playlist or.mpdmanifest, with no query string, fragment or login in the URL, on a public host.
Steps¶
-
Check that the source can be relayed. Nothing is created:
curl -s -X POST "https://<API_HOST>/api/v1/playback/<WORKSPACE_ID>/channels/relay-probe" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "ingestUrl": "https://radio.example.com/live/playlist.m3u8" }'You get
200 OK. Readdata.level:{ "success": true, "data": { "format": "hls", "kind": "master", "linkStyle": "relative", "live": true, "level": "ok", "message": "Fully relayed: playlist and media both go through your cproxy." } }linkStyleExample levelWhat happens relativeseg1.ts,audio/seg1.tsokPlaylist and media both go through the relay node. absolutehttps://cdn.example.com/x.tswarnPlays, but viewers fetch the media straight from the source's host, not cached by you. rootRelative/path/x.ts,../x.tserrorResolves outside the relay and fails; the source is refused. Anything that isn't an HLS playlist or DASH manifest (an
.mp4, a web page, a404, a redirect) iserror. -
Create the channel. A relay channel has exactly one origin, must be
type: "live", and has nostreamerId,ingestConfigortranscodeConfig:curl -s -X POST "https://<API_HOST>/api/v1/playback/<WORKSPACE_ID>/channels" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "name": "City Radio", "sid": 901, "type": "live", "origins": [{ "ingestMode": "external_relay", "ingestUrl": "https://radio.example.com/live/playlist.m3u8" }] }'You get
201 Createdwith the channel indraftstatus. Its origin has the relay address inplaybackUrlHls(HLS source) orplaybackUrl(DASH source). Awarningslist carries thewarnmessage from step 1, if any. The relay is active on the node before the call returns; if it can't be set up, the call returns502and nothing is kept. -
Mark the channel ready, so it can join channel groups:
curl -s -X PATCH "https://<API_HOST>/api/v1/playback/<WORKSPACE_ID>/channels/<CHANNEL_ID>/status" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "status": "ready" }'You get
200 OKwith"status": "ready".
Verify¶
Check the channel's health:
curl -s "https://<API_HOST>/api/v1/playback/<WORKSPACE_ID>/channels/<CHANNEL_ID>/health" \
-H "Authorization: Bearer <ACCESS_TOKEN>"
The relay works when status is healthy and outputRunning is true: the relay's playlist answered, and for an
HLS master playlist so did its first variant. Then open the relay address in a player.
How devices see a relay channel¶
In the device payload an HLS relay's address is in urlHls, and url and publicUrl are empty, so a client must
fall back to urlHls. A DASH relay's address is in url.
Limits¶
- A source URL with a query string, or one that redirects, is refused.
- At most 50 relays per relay node.
- A channel's source can't be changed: delete the channel and create it again. Renaming the channel doesn't change its relay address.
- Only relative links are fully relayed; absolute links bypass the relay's cache and root-relative ones can't be relayed.
- Source hosts that resolve to private or local addresses are refused.
- Sources that reuse segment names can serve stale media for up to about a minute; ask your organization admin to turn segment caching off for such a source.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
400 no cproxy node is set up for external relays |
No relay node is marked for external relays | Ask an organization admin to mark one. |
400 … already carries 50 relays |
The relay node is full | Ask an organization admin to add a node. |
400 with the error message from step 1 |
The source can't be relayed | Pick a source whose links are relative, or one that is a real playlist. |
502 could not set up the relay |
The relay node didn't accept the change | Retry; if it keeps failing, contact your organization admin. |
status is unhealthy |
The source is down or stopped being a valid playlist | Check the source URL in a player. |