Skip to main content

You are viewing Agora Docs forBetaproducts and features. Switch to Docs

Media Gateway event type

After enabling the Notifications service, the Agora server will send a channel event notification callback to your server using the HTTPS POST request method. When the value of the product_id parameter in the callback request body is 10, it means that the Media Gateway event is returned.

This page introduces the types and descriptions for all events returned in the channel event callback.

1 live_stream_connected

The gateway has received the RTMP or SRT stream and successfully entered the channel.

Payload example:


_10
{
_10
"sid": "55df7402-8778-11ee-92ed-07ec2e86c928",
_10
"region": "na",
_10
"streamKey": "7B***Qbs",
_10
"rtcInfo": {
_10
"channel": "123",
_10
"uid": "1234"
_10
},
_10
"beginAt": "2023-11-21T02:27:31Z"
_10
}

The payload contains the following fields:

FieldData typeDescription
sidStringThe unique ID of each streaming session.
regionStringThe server area that has received the pushed stream.
streamKeyStringThe used streaming key.
rtcInfoObjectRTC information:
  • channel: The channel name.
  • uid: The host UID. Supports integer and string data types.
beginAtStringThe start time of the streaming in the RFC3339 format.

This event is usually followed by a corresponding live_stream_disconnected event.

2 live_stream_disconnected

The gateway was disconnected (actively or passively) and left the channel.

Payload example:


_11
{
_11
"sid": "55df7402-8778-11ee-92ed-07ec2e86c928",
_11
"region": "na",
_11
"streamKey": "7B***Qbs",
_11
"rtcInfo": {
_11
"channel": "123",
_11
"uid": "1234"
_11
},
_11
"beginAt": "2023-11-21T02:27:31Z",
_11
"endAt": "2023-11-21T03:27:31Z"
_11
}

The payload contains the following fields:

FieldData typeDescription
sidStringThe unique ID of each streaming session.
regionStringThe server area that has received the pushed stream.
streamKeyStringThe used streaming key.
rtcInfoObjectRTC information:
  • channel: The channel name.
  • uid: The host UID. Supports integer and string data types.
beginAtStringThe start time of the streaming in the RFC3339 format.
endAtStringThe end time of the streaming in the RFC3339 format.

3 live_stream_aborted

The gateway has received an RTMP or SRT stream but terminated it for some reason.

Payload example:


_12
{
_12
"sid": "55df7402-8778-11ee-92ed-07ec2e86c928",
_12
"region": "na",
_12
"streamKey": "7B***Qbs",
_12
"rtcInfo": {
_12
"channel": "123",
_12
"uid": "1234"
_12
},
_12
"beginAt": "2023-11-21T02:27:31Z",
_12
"errorCode": 100,
_12
"reason": "invalid"
_12
}

The payload contains the following fields:

FieldData typeDescription
sidStringThe unique ID of each streaming session.
regionStringThe server area that has received the pushed stream.
streamKeyStringThe used streaming key.
rtcInfoObjectRTC information:
  • channel: The channel name.
  • uid: The host UID. Supports integer and string data types.
beginAtStringThe start time of the streaming in the RFC3339 format.
errorCodeNumberThe stream termination error code.
reasonStringThe error message.

This event may be sent alone or between the connected and disconnected events.

The possible values for the errorCode field include the following:

ValueDescriptionRecommended actions
1Illegal streamKey. For example, channelName is empty or contains illegal characters.Check the streamKey format, especially for locally generated ones.
2Invalid streamKey (expired or deleted)Create a new streamKey and try again.
3No permission to use this streamKey. For example, the customer-defined domain name and streamKey under the associated app ID do not match.Check whether the streamKey matches the domain name used for the push.
4Number of concurrent streams exceeds the limit.Wait and retry.
5Conflict detected, for example, pushing to the same channel and at the same.If the streams are not being pushed at the same time, try again 5-10 seconds later.
6The stream attribute exceeds the limit (currently applies to bitrate only).Check the streaming software configuration and lower the target bitrate.
7Streaming without any audio or video data for more than 10 secondsCheck whether the last push exited abnormally, and then try again.
8Failed to join channelThe reason field will provide the specific error reason, for example: "connect to rtc failed, reason:$N". Refer to the API documentation for details.
9Disconnected from the main network. Specific reasons need to be investigated by contacting technical support.Try again several times. If you still have problems, contact technical support to confirm whether the app certificate provided during activation is valid.
10Unknown internal service error. Specific reasons need to be investigated by contacting technical support.Try again a few times. If you still have problems, contact technical support.

4 live_profile_updated

Stream properties have been updated. For example, the first audio or video frame has been received or the audio or video profile has changed.

Payload example:


_19
{
_19
"sid": "55df7402-8778-11ee-92ed-07ec2e86c928",
_19
"region": "na",
_19
"streamKey": "7B***Qbs",
_19
"rtcInfo": {
_19
"channel": "123",
_19
"uid": "1234"
_19
},
_19
"videoProfile": {
_19
"codec": "H.264",
_19
"width": 1920,
_19
"height": 1080
_19
},
_19
"audioProfile": {
_19
"sampleRate": 48000,
_19
"channels": 2
_19
},
_19
"beginAt": "2023-11-21T02:27:31Z"
_19
}

The payload contains the following fields:

FieldData typeDescription
sidStringThe unique ID of each streaming session.
regionStringThe server area that has received the pushed stream.
streamKeyStringThe used streaming key.
rtcInfoObjectRTC information:
  • channel: The channel name.
  • uid: The host UID. Supports integer and string data types.
videoProfileObjectVideo properties. Not applicable for audio-only streams.
  • codec: Video codec format, such as "H.264", "H.265", "VP8", "VP9", "AV1", and so on.
  • width: Video width.
  • height: Video height.
audioProfileObjectAudio properties:
  • sampleRate: The sampling rate in Hz.
  • channels: The number of channels.
beginAtStringThe start time of the streaming in the RFC3339 format.
vundefined