Configuring Event Notifications

The Live service uses Simple Message Notification (SMN) to notify event status in real time. Before using this function, configure SMN. SMN charges you for notification messages. For details, see SMN Pricing Details.

Background

  • A topic is a specified event for message publishing or subscription notification. It serves as a message sending channel, where publishers and subscribers can interact with each other. Before configuring event notifications, you must customize a topic.
  • Subscription is to associate a subscriber to a topic. A user can have multiple topics, and each topic has multiple subscribers.
  • Message subscription configurations take effect for all domain names with the same project ID.

Process Flow

Figure 1 shows the process of configuring event notifications.

Figure 1 Process of configuring event notifications
  1. Create a topic on the SMN console.
  2. Add a subscription: add a topic to a subscription. After you subscribe to the topic and confirm subscription, endpoints can receive all messages published to the topic.
  3. Configure a topic policy to authorize Live to publish messages to the topic.
  4. Configure event notifications on the Live console to receive notifications when live stream pushing starts and ends and during recording.

Prerequisites

  • Domain names have been added.
  • CNMAE records have been added to your domains' DNS records.

Step 1: Create a Topic

  1. Log in to the SMN console.
  2. In the navigation pane, choose Topic Management > Topics.
  3. Click Create Topic and set parameters including Topic Name.

    Figure 2 Creating a topic

  4. Click OK.

Step 2: Add a Subscription

  1. In the navigation pane of the SMN console, choose Topic Management > Topics.
  2. Locate the topic to which you want to add a subscription, click More under Operation, and select Add Subscription.
  3. Specify the subscription protocol and endpoints.

    Figure 3 Adding a subscription

    Table 1 describes the subscription parameters.

    Table 1 Subscription parameters

    Parameter

    Description

    Topic Name

    Name of the topic to be subscribed to. Retain the default value.

    Protocol

    Message notification method. Select a protocol from the drop-down list.

    The common protocols used by Live are SMS, email, and HTTP/HTTPS.

    • SMS

      A received phone message contains the message body only.

    • Email

      A received email contains the message body and a link to unsubscribe.

    • HTTP/HTTPS

      If the subscription endpoint is a public network website, SMN sends HTTP/HTTPS notifications to the endpoint, including the HTTP header and HTTP content. The HTTP/HTTPS content is a JSON character string. For details, see HTTP/HTTPS Message Format.

    Endpoint

    Subscription endpoint. You can enter up to 10 SMS, email, HTTP, or HTTPS endpoints, one in each line.

    • SMS: Enter one or more valid phone numbers.

      The phone number must be preceded by a plus sign (+) and a country code. If you enter a mobile number in the Chinese mainland, the plus sign (+) and country code can be omitted.

      Examples:

      +8600000000000

      +8600000000001

    • Email: Enter one or more valid email addresses.

      Examples:

      username@example.com

      username2@example.com

    • HTTP or HTTPS: Enter one or more public network URLs.

      Examples:

      http://example.com/notification/action

      http://example2.com/notification/action

  4. Receive a subscription confirmation message and confirm subscription. If the subscription endpoint is email, you will receive an email which looks like Figure 4. Confirm it. Then you will receive messages published to the topic.

    Figure 4 Message subscription confirmation

Step 3: Configure a Topic Policy

  1. In the navigation pane of the SMN console, choose Topic Management > Topics.
  2. Click More > Configure Topic Policy in the Operation column.
  3. Set topic policy parameters.

    Figure 5 Configuring a topic policy

    Topic policies are classified into basic mode and advanced mode. The basic mode simply specifies which users or cloud services have permissions to publish messages to a topic. See Table 2.

    Table 2 Description for configuring topic policies in basic mode

    Item

    Parameter

    Description

    Users who can publish messages to this topic

    Topic creator

    Only the topic creator has the permission to publish messages to the topic.

    All users

    All users have the permission to publish messages to the topic.

    Specified user accounts

    Only specified users have the permission to publish messages to the topic.

    Users are specified in the format of urn:csp:iam::domainId:root,

    in which domainId indicates the account ID of a user. Every two users are separated with a comma (,). SMN does not limit the number of users you can specify, but the total length of a topic policy cannot exceed 30 KB.
    NOTE:
    • Enter the account ID of the user and click OK. Other information is automatically supplemented by the system.
    • To obtain a user's account ID, log in to the SMN console, hover the mouse over the username in the upper right corner and choose My Credentials from the drop-down list.

    Services that can publish messages to this topic

    See the preceding figure.

    Select LIVE. Live has the permissions to access the topic.

Step 4: Configure Event Notifications

  1. Log in to the Live console.
  2. In the navigation pane, choose Domains.
  3. Click Settings in the row containing the target streaming domain name.
  4. In the navigation pane, choose Template Settings > Notifications.

    For details about a message template, see Recording Message Template.

    Figure 6 Message subscription template

  5. In the row containing the target template, click Edit.

    Figure 7 Template settings
    • Template Name: name of a recording message template, which cannot be changed.
    • Topic: Click to add a topic created in SMN.
    • Notification Status: Select Enable so that subscription endpoints can receive notifications.

  6. Click OK.

Recording Message Template

The following shows a recording message template. Table 3 describes the fields in the message.

Live Record Notify, domain: {domain}, app_name: {app_name}, stream_name: {stream_name}, download_url: {download_url},  filename: {filename},asset_id: {asset_id}, duration: {duration}, event: {event}, timestamp: {timestamp}
Table 3 RecordNotifyTemplate parameter description

Parameter

Description

domain

Ingest domain name

app_name

Application name, which is the same as the value of AppName in an ingest URL.

stream_name

Live stream name

download_url

Address for downloading recordings. If the value of event is not RECORD_NEW_FILE, this parameter is left blank.

filename

Name of a recording. If the value of event is not RECORD_NEW_FILE, this parameter is left blank.

asset_id

Media ID of a recording, which is the unique ID allocated by the VOD service. If the value of event is not RECORD_NEW_FILE, this parameter is left blank.

duration

Length of a recording. If the value of event is not RECORD_NEW_FILE, this parameter is 0.

event

Recording event. The options are as follows:

  • RECORD_START
  • RECORD_NEW_FILE
  • RECORD_OVER
  • RECORD_FAIL

timestamp

Recording timestamp