Skip to main content

Explaining sessions

Sessions within MistServer are connections, these could be viewers, inputs, outputs or unspecified. More specifically it would indicate when a connection is considered new or not. Some protocols would open and close connections consistently, or viewers might switch between protocols. Would you consider those changes "new" or simply 1 viewer.

Before 3.2 we'd counted a session based on parameters per connection, these were parameters like: IP address, Token, Protocol and stream name. With 3.2 we have the same parameters, but we have opened up the settings on when/what is considered a new connection.

Now the reason why this is important for most people is to more accurately determine viewer numbers for a stream. If you know what is used to decide whether someone is a new viewer you'll have more faith in the numbers reported back to you.

Another thing to keep in mind is that by default Sessions within Mistserver time out after 15 seconds, denied session keep stored for 10minutes. This means that a Session will be remembered for 10 minutes after it's been inactive and then be considered a new session if reconnecting. You can speed up this process with an INVALIDATE_SESSIONS API call.

Setting up sessions

Sessions can be set up in the General panel of MistServer or directly through the API. We recommend using the interface and later on copying the config settings to other MistServer instances as that's an easier method.

Token settings

Tokens were known as Session IDs or SIDs before MistServer 3.2 and were mostly undocumented. They have now been rewritten to be Tokens. Tokens are unique strings per process that can be used to keep track of the same user/process switching between protocols or streams.

Token settings determine how a Token is made or used. For inputs and outputs the process ID (PID) of the process handling the in or output will be used. For viewers an Cookie or URL parameter can be used. The settings allow you to both read or write these to a Cookie or URL parameter. In general we would recommend writing to both Cookie and URL parameter as it'll give the biggest guarantee a viewer will be registered as the same. One thing of note here is that an URL parameter will always have priority above a Cookie if both are used. In order to set your own manual Cookie or URL parameter simply set your own "tkn=value".

Viewer, Input, Output and Unspecified sessions

These are the types of sessions that can be connected to MistServer. Note that processes can be present as both an input and output at the same time as MistServer would first "output" the given stream data into a new process handling the "input", we will add the option to make MistServer ran processes as unspecified processes in the future.

Viewer sessions

Viewers are pretty straightforward, these are the people watching streams and most likely the ones you are most interested in. You can set up MistServer to determine a new session based on 4 variables:

  • Stream name The Stream the viewer is watching
  • IP address The IP address the viewer is connecting from
  • Token The Token reported back by URL paramater then Cookie
  • Protocol The stream protocol in use (HLS, MP4, etc)

Our defaults here are to consider someone a new viewer when Stream name, Token or IP address changes. As most viewers generally do not switch between Token or IP address this means a viewer can switch between protocols and still be counted as the same connection. However if the viewer switches to a different stream completely it'll count as a new viewer for that stream.

Input sessions

Input sessions are connections coming into MistServer as a stream source. These could be pushes coming into MistServer, processes ran by MistServer but also MistServer pulling from other locations. A session can be determined based on 4 variables:

  • Stream name The Stream the input is providing
  • IP address The IP address the input is coming from
  • Token The PID handling the input at the MistServer side
  • Protocol The stream protocol in use (RTMP, SRT, HLS, etc)

Our defaults here are to consider something a new input when Stream name, IP address and Token are different. This would mean that every unique push into MistServer is considered a new input session.

Output sessions

Output sessions are connections going out of MistServer that are not viewers. These could be pushes to local file, other servers or processes ran by MistServer. A session can be based on 4 variables:

  • Stream name The Stream MistServer is pushing
  • IP address The IP address of the target location
  • Token The PID doing the push at the MistServer side
  • Protocol The stream protocol in use (RTMP, SRT, HLS, etc.)

Our defaults here are to consider something a new output when Stream name, IP address and Token are different. This would mean that every unique push out of MistServer is considered a new output session.

Unspecified sessions

These are the sessions that could be considered as something else than a Viewer, Input or Output. There is no "default" unspecified session, but we've added the option to consider some requests/processes unspecified to discount them from any Trigger or Analytic usage. The HTTP JSON request for stream information the MistServer player does before playback can be selected as such a protocol. We plan to add the option to consider stream processes as unspecified option as well. An unspecified session can be based on 4 variables:

  • Stream name The Stream name relevant to the session
  • IP address The IP address this session is connecting from or to
  • Token The Token reported back by URL paramater then Cookie or PID
  • Protocol The stream protocol in use (HTTP, SRT, etc)

Our defaults here are to use none of the variables. Mostly because we assume you point something to an unspecified session because you specifically want it gone from your analytics or trigger requests. Therefore we do not create any sessions for unspecified sessions as a default.