Sessions API
Sessions are the active client connections to HTTP MPEG-TS and HLS outputs and to SRT outputs in listener mode. They are not the login sessions of the web interface: those are created and revoked by the Authentication API.
Get session list
Section titled “Get session list”Request: GET /api/sessions or POST /control/. Control on the path entry point; control and observer on the command entry point. An observer calling GET /api/sessions receives 404.
{ "cmd": "sessions"}The path form takes no body. A second path segment (/api/sessions/anything) is ignored.
Response:
{ "sessions": [ { "client_id": 47311928, "channel_id": "a001", "channel_name": "Channel Name", "addr": "192.168.1.10", "login": "viewer", "ua": "VLC/3.0.20 LibVLC/3.0.20", "uptime": 128 } ]}client_id- number, the session identifier: a random integer between 10000000 and 99000000, unique among the running sessions. Theidofclose-session.channel_id- string, optional. Theidof the stream the client plays.channel_name- string, optional. Thenameof the stream.addr- string, optional. For HTTP clients the client IP address: the peer address, or theX-Real-IPheader when the HTTP authentication optionx_real_ipor theallow_real_ipsetting is enabled (a header value that is not an IP address falls back to the peer address). For SRT clients the peeraddress:port.login- string, optional. The login the authorization chain granted the session to, for example the user matched by itstokenorip. Absent when the channel has no authorization or the client was granted without a user.ua- string, optional. TheUser-Agentheader of an HTTP client;srtfor an SRT client.uptime- number, seconds since the session started.
An optional field is left out of the object when it has no value. An HTTP session is listed from the moment the request arrives, before its authorization completes, so a row may appear a moment before its login does. The order of the list is not defined.
Example:
curl --user login:password http://server:8000/api/sessionsClose session
Section titled “Close session”Request: POST /control/. Control only.
{ "cmd": "close-session", "id": 47311928}id- number or numeric string, required. Theclient_idfrom the session list.
Response:
{ "close-session": "ok" }The reply is ok whether or not a session with that id existed; an id that is not a number closes nothing. An HTTP MPEG-TS connection is closed, an HLS session is removed from its channel and its next media playlist request is answered 404. SRT client sessions are listed but cannot be closed with this command.
Example:
curl \ -X POST \ --user login:password \ -d '{"cmd":"close-session","id":47311928}' \ http://server:8000/control/