Skip to content

Streaming Sessions

Here you will learn what session types exist in Flussonic and what you should know about them.

When a user starts watching a TV channel, he starts a play session in Flussonic terminology. He switches to another channel, it will be another session. Before version 21.02 play sessions were the only kind of sessions that were accounted and reported via events system. You know these sessions from authorization system.

In Flussonic 21.03 new types of sessions appear:

The following table classifies the 4 kinds of video streaming sessions based on how each type of session is initiated: ingest, publish, play, and push.

to Flussonic from Flussonic
user starts publish play
Flussonic starts ingest push

Session lifecycle

Flussonic has a unified lifecycle for all kinds of sessions listed above. Each session is in some state and transitioning from one state to another will issue some event.

For convenience, ingest and publish sessions issue events under the same name: source.


Here is an example:

  • User makes the first HLS request. The play_opened event is emitted as new play session is opened.
  • Authorization backend allows this session, so play_authorized event is emitted
  • The player starts fetching segments, this session passes the threshold and now it is considered started with play_started event
  • While user watches this stream, periodically the play_updated event is emitted that can be used to save this session info to the middleware.
  • After some timeout since the last request, the session is considered closed with the corresponding play_closed event.

Events and session states


We'll name session states with a capital letter, while events and session types — with a lowercase letter.

When a session opens, its state changes from None to Establishing, and the event opened is generated at this moment. The Establishing state means that the session is not doing any valuable things yet, but it is trying to do them: connecting, preparing, and checking authorization.

A session can always exit with the event closed and go into the state Finished.

Sessions publish and play can get the authorized event in Establishing state and while Running.

A session in the Establishing state waits for a first frame or keyframe if it is a source session (ingest/publish), or waits till enough bytes of output for play/push. Then it becomes Running with the started event.

A Running session is updated periodically and you can use this event to track this session. Use the updated event to update your database record for this session as it will overwrite previous data about this session.

A Running session can be altered if the input/output bitrate has changed or media_info has changed.

A Running play or push session can be overflowed if it cannot send output data as fast as it is required. A source (ingest/publish) session can be overflowed only if the underlying protocol can inform us about that just like RTSP/RTCP or SRT can do.

A Running session can even change with stalled to Stalling if it cannot transfer data anymore. This state occurs if it is possible for the session to become recovered back to Running.

Externally initiated sessions like play or publish should be authorized on an external authorization system. This external system must respond to periodic pings on each session and sometimes it can terminate a session with the denied event.

Session fields

You can get all these sessions via the Flussonic's HTTP events sink mechanism as JSON objects.

Here is the list of fields.


This list may be a subject to change in the future. We will try to keep compatibility as long as possible, but all things should evolve. Also, Flussonic can send additional undocumented fields. We do not recommend using them, because they can be changed or removed at any moment.

Field Name Type Description
opened_at integer milliseconds session creation time
id string uuid session unique ID
ip string ip peer IP (client, source, push target, etc
proto string protocol exact protocol that is used for video delivery
media string stream/file name
bytes integer bytes transmitted in this session
duration integer milliseconds duration of this session. Will not change after closed event
user_id string user_id provided by auth backend for this session
token string user provided auth token

How to configure events

Add a notify section, here is an example from our lab:

notify example {
  sink http://mywebserver/event.php;
  only media=example;

stream example {
  url tshttp://;

This configuration will send HTTP POST requests with JSON body containing sessions described in the section above. Raw messages are too long to show them here but I'll show just some of them.

Source connection events

In the example you can see a series of events when Flussonic connects to the source:

  • source_connected — an HTTP connection ("status":"http_connect") was started.

  • source_startedsource_id=7ad153b1-68a5-4304-bbfd-b136603baebd was created.

  • stream_updatedbytes, bytes_out for source_id=7ad153b1-68a5-4304-bbfd-b136603baebd were updated.


Playback started event

You'll receive the event play_opened when a client connects to a stream via HLS:

    "token":"test","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36",

Note that "source_id":"82c59180-e64e-42fc-8f11-2dec111ca5f7" is the same ID that we got in the previous example. All events are linked to each other via the source_id parameter.