Suggestions

close search
Speed up your development
Create a Fast Track

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

Session Monitoring

Register to receive real-time session event callbacks and monitor your session activity from your app server.

Using the OpenTok platform, developers can monitor certain activity of clients using OpenTok client SDKs, from within their app server. By registering for callbacks with the OpenTok REST API, your callback URL will receive HTTP POST requests when any sessions are created and destroyed, clients connect and disconnect, and clients publish and unpublish streams to a session in your OpenTok project. Additionally, you can register a callback to monitor events related to OpenTok archives for your project.

Registering callbacks

Session events and archive status updates information can all be registered to HTTP endpoints within your server. Whenever registered activity occurs, an HTTP request is issued from OpenTok infrastructure to your endpoint.

To register a callback:

  1. Visit your Vonage Video API account page.

  2. Select the OpenTok project for which you want to register a callback.

  3. Set the callback URL in the Session Monitoring section.

    Secure callbacks: You can secure webhook callback requests with signed callbacks, using a signature secret. See Secure callbacks.

The archive callback URL and broacast callback URL are set separately from the the callback URL for session events. Set the archive callback URL in the Archive section of your Vonage Video API account page.

Important: The session monitoring service no longer disables event forwarding in the case of excessive delivery failures (as was the case in previous versions), since a retry and backoff mechanism is used. You will no longer receive emails on session monitoring callback disruptions, since the service will not be suspended or disabled.

Monitoring when sessions start and stop

When clients first start using a session and when a session stops being used, sessionCreated and sessionDestroyed events are sent to your registered callback endpoint.

Session created

This event is sent when the first client connects to a session. If all clients disconnect (see Session destroyed), clients can later reconnect to the same session.

For each distinct event, the server sends an HTTP POST request to the callback URL you supply. The Content-Type for the request is application/json. The data of the request is a JSON object of the following form:

{
  "sessionId": "2_MX4xMzExMjU3MX5-MTQ3MDI1NzY3OTkxOH45QXRr",
  "projectId": "123456",
  "event": "sessionCreated",
  "timestamp": 1470257688309,
  "createdAt": 1470257688309
}

The JSON object includes the following properties:

Session destroyed

This event is sent when a session stops being used:

After this event is dispatched, you can still reuse the session. Clients can reconnect to the session using the same session ID Session created callback event will be sent. However, it is a better practice to have clients reconnect using a new session ID.

Also, as a best pratice, you should have clients reconnect to new sessions (using a new session ID), within 8 hours of the Session created callback event.

For each distinct event, the server sends an HTTP POST request to the callback URL you supply. The Content-Type for the request is application/json. The data of the request is a JSON object of the following form:

{
  "sessionId": "2_MX4xMzExMjU3MX5-MTQ3MDI1NzY3OTkxOH45QXRr",
  "projectId": "123456",
  "event": "sessionDestroyed",
  "timestamp": 1470258896953,
  "createdAt" : 1470258896953,
  "reason" : "clientDisconnected"
}

The JSON object includes the following properties:

Session notification events

The sessionNotification event is sent when a group of Video API servers for one of your sessions is scheduled to be rotated.

The sessionNotification event is an HTTP POST request sent to session monitoring callback URL you supply. The Content-Type for the request is application/json. The data of the request is a JSON object of the following form:

{
  "sessionId": "2_MX4xMzExMjU3MX5-MTQ3MDI1NzY3OTkxOH45QXRr",
  "projectId": "123456",
  "event": "sessionNotification",
  "reason": "serverRotation",
  "timestamp": 1470282888309,
  "remainingTime": 3600,
  "createdAt": 1470257688309
}

The JSON object includes the following properties:

See Server Rotation for more information on Video API server rotations and how to keep clients connected when server rotations occur.

Monitoring connection activity

Once properly registered, OpenTok infrastructure can send HTTP requests for all connections made (and destroyed) to all sessions for a single project. This is particularly useful for tracking user availability without requiring additional connections or reporting directly from the endpoint.

When clients receive connectionCreated and connectionDestroyed events in response to other clients connecting to and disconnecting from a session, these same events are sent to your registered callback endpoint.

Connection created

For each distinct event, the server sends an HTTP POST request to the URL you supply. The Content-Type for the request is application/json. The data of the request is a JSON object of the following form:

{
    "sessionId": "2_MX4xMzExMjU3MX5-MTQ3MDI1NzY3OTkxOH45QXRr",
    "projectId": "123456",
    "event": "connectionCreated",
    "timestamp": 1470257688309,
    "connection": {
        "id": "c053fcc8-c681-41d5-8ec2-7a9e1434a21e",
        "createdAt": 1470257688143,
        "data": "TOKENDATA"
    }
}

The JSON object includes the following properties:

Connection destroyed

For each distinct event, the server sends an HTTP POST request to the URL you supply. The Content-Type for the request is application/json. The data of the request is a JSON object of the following form:

{
    "sessionId": "2_MX4xMzExMjU3MX5-MTQ3MDI1NzY3OTkxOH45QXRr",
    "projectId": "123456",
    "event": "connectionDestroyed",
    "reason": "clientDisconnected",
    "timestamp": 1470258896953,
    "connection": {
        "id": "c053fcc8-c681-41d5-8ec2-7a9e1434a21e",
        "createdAt": 1470257688143,
        "data": ""
    }
}

The JSON object includes the following properties:

Monitoring streams

Server endpoints can also register to receive HTTP requests triggered by stream activity on all sessions for a given project. When streams are created and destroyed, the request will contain stream and connection data for the stream that triggered the event.

When clients receive streamCreated and streamDestroyed events in response to other clients publishing to a session, these same events are sent to your registered callback endpoint.

Stream created

For each distinct event, the server sends an HTTP POST request to the URL you supply. The Content-Type for the request is application/json. The data of the request is a JSON object of the following form:

{
    "sessionId": "2_MX4xMzExMjU3MX5-MTQ3MDI1NzY3OTkxOH45QXRr",
    "projectId": "123456",
    "event": "streamCreated",
    "timestamp": 1470258860571,
    "stream": {
        "id": "63245362-e00e-4834-8371-9397deb3e452",
        "connection": {
            "id": "c053fcc8-c681-41d5-8ec2-7a9e1434a21e",
            "createdAt": 1470257688143,
            "data": ""
        },
        "createdAt": 1470258845416,
        "name": "",
        "videoType": "camera"
    }
}

Stream destroyed

For each distinct event, the server sends an HTTP POST request to the URL you supply. The Content-Type for the request is application/json. The data of the request is a JSON object of the following form:

{
    "sessionId": "2_MX4xMzExMjU3MX5-MTQ3MDI1NzY3OTkxOH45QXRr",
    "projectId": "123456",
    "event": "streamDestroyed",
    "reason": "clientDisconnected",
    "timestamp": 1470258896953,
    "stream": {
        "id": "63245362-e00e-4834-8371-9397deb3e452",
        "connection": {
            "id": "c053fcc8-c681-41d5-8ec2-7a9e1434a21e",
            "createdAt": 1470257688143,
            "data": ""
        },
        "createdAt": 1470258845416,
        "name": "",
        "videoType": "camera"
    }
}

Monitoring archives

Each archive goes through multiple states through the lifespan of the archive. For every status update that occurs, a server endpoint with an archive status registration will receive an HTTP request. This is particularly useful for triggering post-processing of an archive, or for performing any necessary administrative tasks after an archive has been uploaded to persistent storage. For more information see the Archive status changes section of the OpenTok archiving developer guide.

Monitoring broadcasts

See the Monitoring live streaming broadcast status changes section of the OpenTok live streaming broadcasts developer guide.

Monitoring SIP call progress

You can monitor status updates for SIP connections to OpenTok session. See the Monitoring call progress section of the OpenTok SIP Interconnect developer guide.

Monitoring Experience Composer

You can monitor status updates for Experience Composers. See the Configuring callbacks section of the Experience Composer developer guide.

Monitoring live captions

You can monitor status updates for live captions. See the Live caption callbacks section of the live captions developer guide.