Push tokens through stream keys
What is live streaming with tokens
Live streaming with tokens allows you to provide streamers with security in their RTMP/SRT/WebRTC push URL, while also offering a more user-friendly stream name for viewers and channels. By default, RTMP exposes the stream name in the push URL. While convenient, this can make it easy for others to "hijack" the stream if the URL is guessed.
Using tokens allows you to push with complex stream keys while keeping the stream name within MistServer simple and user-friendly. Starting with MistServer 3.7, the stream keys feature enables this functionality through a straightforward interface.
Stream name vs Stream key vs token
Since the wording can become a bit confusing it might be best to explain the differences between a stream key
and stream name
.
Essentially there are none, stream name
and stream key
are both used to refer to a Stream within MistServer using a unique name
as identifier. It might be easiest to see the stream name
as how MistServer recognizes the stream
and the stream key
as an alias to use to refer to the same thing. The major difference is that changing the stream key
is more flexible and doesn't change any playback endpoints, while changing the stream name
would impact the playback endpoints.
Other applications tend to refer to this same identifier as key
, name
or token
. Which is the same thing and simply gives the server a unique identifier
to recognize the stream.
Requirements
- MistServer 3.7+
Steps to go through
- Setting up a stream key
- (Optional) Setting up a stream to only allow stream key pushes
- Pushing to the stream key using RTMP
- Pushing to the stream key using SRT
- Pushing to the stream key using WebRTC
For the examples below, we assume MistServer is running on its default ports: 1935
for RTMP, 8889
for SRT, and 8080
for HTTP. If you're using different ports, make sure to adjust the port numbers accordingly.
1. Setting up a stream key
Stream keys can be created from the streams
panel.
You’ll find a stream key button at the top of the page:
From there, you can create a stream key and have MistServer generate a token. Keep in mind that a stream key
is optional for any stream name
that is already configured in MistServer. Adding a stream key
will allow another method of pushing a stream towards that stream name
into MistServer. If you want to lock this down to only allow stream keys
to push towards MistServer please look at step 2.
You can also create a stream key
for a stream name
that does not exist within MistServer. That stream will then be created on the fly using the MistServer default live stream configurations, which should suit most users.
There is no limit on the amount of stream keys
that can point to a single stream name
. However each stream key
within MistServer must be unique.
You can also set up a stream key
for a wildcard stream
within MistServer
You can click the stream key to copy it:
Or click the stream name to configure the stream for the optional Step 2:
2. (Optional) Setting up a stream to only allow stream key pushes
If you arrived here by clicking the stream name and pressing the "Create Stream" button, you’ll notice all required information is already set up, including the stream key info. Since you created a stream key
first we assume you want to enforce this when pushing the stream towards MistServer. Keep in mind that it is hidden under a tab that can be expanded. When expanded, it looks like this:
If this is your starting point, you will need to fill in all information manually. Be sure to add push://
as a source; otherwise, the stream key
tab won't be accessible.
You can also set any optional parameters here. If you later use this stream name
as a wildcard target for other streams, they will inherit these settings.
3. Pushing to the stream key using RTMP
In this example, we’ll use OBS, but the process is similar for any application capable of RTMP push.
Simply replace the stream name
with the stream key
:
- URL:
rtmp://mistserveraddress/live/
- Stream key:
9p6iKigoFluD1WcUeRtp3pNTxpvp0fMQ
Once you start streaming, your stream should appear active in both the stream keys
panel and the streams
panel:
If a stream isn’t permanently configured, it will appear in blue. This means it will only exist while the stream is live and will automatically disappear afterward. You can right-click and create the stream to make the setup permanent, but it's not required.
Some applications may not have a stream key
field. In such cases, append the stream key to the end of the URL like so:
- Full address:
rtmp://mistserveraddress/live/9p6iKigoFluD1WcUeRtp3pNTxpvp0fMQ
4. Pushing to the stream key using SRT
For SRT, make sure to use the streamid
parameter in your push URL. Using our example:
srt://mistserveraddress:8889?streamid=9p6iKigoFluD1WcUeRtp3pNTxpvp0fMQ
In OBS, leave the stream key field empty:
If a passphrase is set up for the SRT protocol in MistServer’s protocols tab, you must include it in your push setup. Stream keys do not override SRT passphrase requirements.
5. Pushing to the stream key using WebRTC
For WebRTC, target either the HTTP or HTTPS port and use the following format:
http://mistserveraddress:8080/webrtc/9p6iKigoFluD1WcUeRtp3pNTxpvp0fMQ
https://mistserveraddress:5544/webrtc/9p6iKigoFluD1WcUeRtp3pNTxpvp0fMQ
(Want to know how to set up HTTPS? Look here!)
Some systems may modify stream keys by removing case sensitivity. If your stream key doesn't work, try generating one using only lowercase characters.
Using Stream keys with other features within MistServer
Recording
You can set up (automatic) recordings/pushes for streams using a stream key
and aren't configured otherwise. In the case of automatic recording/pushes MistServer will activate those when a matching stream name
becomes active. Regardless of whether it is configured.
Triggers
If triggers are set up to activate on all streams and not specific ones any stream created through a stream key
will activate the trigger. The only exceptions are triggers that determine whether stream push is allowed such as: PUSH_REWRITE
, RTMP_REWRITE
and STREAM_SOURCE
, those are bypassed completely
Playback urls
MistServer will generate the same playback url endpoints for these streams as any other. So you can set up other locations to pull from MistServer.
Analytics
Statistics for both the stream and the viewers are still gathered & can be reached.
Push vs Pull and load balancing
Keep in mind that stream keys
affect PUSH inputs only. So if you have multiple MistServers and a load balancer your setup will be affected if you've set servers up to push to each other. Our recommended setup for using stream keys
in combination of a load balancer is having the servers pull from each other. That way they're never affected by stream keys
.