Format of stream ingest callbacks

Updated at:

If you configure callbacks for stream ingest status, you can receive callback notifications about successful or interrupted stream ingest in a timely manner.

How it works

ApsaraVideo Live sends an HTTP GET request to your server to notify you of the successful or interrupted stream ingest in real time. The server then responds with the HTTP status code 200, which indicates that the callback is successful.

Usage notes

  • A callback URL requires no identifier but must be accessible. The URL response complies with the following requirements:

    If access to the callback URL times out, ApsaraVideo Live retries to access the URL. The timeout period is 5 seconds. ApsaraVideo Live performs up to five retries at intervals of 1 second.

  • Callback logic for the publish status in ingest and disconnection callbacks

    1. For RTMP stream ingest, if the ingest client does not disconnect within 2 seconds after the ApsaraVideo Live service receives an On Publish message, ApsaraVideo Live sends a callback to indicate a successful ingest.

    2. If you have an ingest domain A and a streaming domain B, and you want to receive callbacks for stream pulling on domain B (scheduled or triggered back-to-origin pulling), you must configure an Ingest Callback for domain A. After the configuration, the callback logic for stream pulling on domain B is the same as described in the preceding item. A successful connection is assumed if the stream is not actively disconnected within 2 seconds after the connection is established.

    Note
    • In addition to using callback notifications to determine whether stream ingest and stream pulling are successful, we recommend that you also use the Query the list of active streams for a domain API to verify that stream ingest is successful before you distribute the live stream playback URL.

    • If no streaming data is pushed to the live center for 10 seconds, the ApsaraVideo Live service automatically disconnects the stream ingest.

  • Stream ingest callback logic

    By default, authentication for stream ingest callbacks is disabled. You can enable the feature when you specify the stream ingest callback URL. After you enable the feature, the following authentication logic applies:

    1. When ApsaraVideo Live initiates a callback request, it includes the ALI-LIVE-TIMESTAMP and ALI-LIVE-SIGNATURE headers in the HTTP or HTTPS request so that the callback message receiving server can authenticate the signature. The value of ALI-LIVE-SIGNATURE is calculated based on the following formula:

      ALI-LIVE-SIGNATURE = MD5SUM (MD5CONTENT)

      MD5CONTENT = Domain name|ALI-LIVE-TIMESTAMP value|Cryptographic key

      Note
      • Domain name is the ingest domain for which you configure the callback URL.

      • Cryptographic key is the key that you configure for the callback URL.

      • Request header names are case-insensitive.

    2. After receiving a callback message, the callback message receiving server concatenates the domain name of the callback, value of the ALI-LIVE-TIMESTAMP header, and cryptographic key in the preceding format. The server calculates the MD5 value of the string to obtain an encrypted string. Then, the server compares the encrypted string with the value of the ALI-LIVE-SIGNATURE header in the HTTP or HTTPS request initiated by ApsaraVideo Live. If the two values are different, the request is invalid.

Example

Sample callback:

http://1.1.1.1?action=publish&ip=192.168.XX.XX&id=world&app=example.aliyundoc.com&appname=liveApp****&time=1609220385&usrargs={Custom parameters}&
node=cdnvideocenter01020711****.cm3&height=720&width=1280

Parameter

Description

action

The event. Valid values:

  • publish: stream ingest

  • publish_done: stream interruption

ip

The IP address of the stream ingest client.

id

The name of the ingested stream.

app

The ingest domain. The default value is a custom ingest domain. If no ingest domain is available, a streaming domain is used.

appname

The name of the application that ingests the stream.

time

The UNIX timestamp. Unit: seconds.

usrargs

The custom parameters that are used to ingest the stream.

node

The name of the CDN point of presence (POP) or the host that receives the stream.

height

The height of the resolution. Unit: pixels.

Note

The height and width of the resolution are returned only when the callback is invoked for the first time.

width

The width of the resolution. Unit: pixels.