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:
The payload contains the following fields:
| Field | Data type | Description |
|---|---|---|
sid | String | The unique ID of each streaming session. |
region | String | The server area that has received the pushed stream. |
streamKey | String | The used streaming key. |
rtcInfo | Object | RTC information:
|
transcoding | Object | Transcoding configuration information used for streaming. For specific field information, refer to the description of the transcoding field in the Create or reset template. |
beginAt | String | The start time of the streaming in the RFC3339 format. |
This event is followed by a corresponding live_stream_disconnected event.
2 live_stream_disconnected
The gateway has actively or passively disconnected and left the channel.
Payload example:
The payload contains the following fields:
| Field | Data type | Description |
|---|---|---|
sid | String | The unique ID of each streaming session. |
region | String | The server area that has received the pushed stream. |
streamKey | String | The used streaming key. |
rtcInfo | Object | RTC information:
|
streamStats | Object | Statistics for this stream, including:
|
beginAt | String | The start time of the streaming in the RFC3339 format. |
endAt | String | The 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. This event may be sent individually or between live_stream_connected and live_stream_disconnected events.
Payload example:
The payload contains the following fields:
| Field | Data type | Description |
|---|---|---|
sid | String | The unique ID of each streaming session. |
region | String | The server area that has received the pushed stream. |
domain | String | The domain used for streaming. |
streamKey | String | The used streaming key. |
rtcInfo | Object | RTC information:
|
beginAt | String | The start time of the streaming in the RFC3339 format. |
errorCode | Number | The stream termination error code. |
reason | String | The error message. |
The possible values for the errorCode are:
| Value | Description | Recommended actions |
|---|---|---|
1 | Illegal streamKey. For example, channelName is empty or contains illegal characters. | Check the streamKey format, especially for locally generated ones. |
2 | Invalid streamKey (expired or deleted) | Create a new streamKey and try again. |
3 | No 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. |
4 | Number of concurrent streams exceeds the limit. | Wait and retry. |
5 | Conflict 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. |
6 | The stream attribute exceeds the limit (currently applies to bitrate only). | Check the streaming software configuration and lower the target bitrate. |
7 | Streaming without any audio or video data for more than 10 seconds | Check whether the last push exited abnormally, and then try again. |
8 | Failed to join channel | The reason field will provide the specific error reason, for example: "connect to rtc failed, reason:$N". Refer to the API documentation for details. |
9 | Disconnected 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. |
10 | Unknown 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:
The payload contains the following fields:
| Field | Data type | Description |
|---|---|---|
sid | String | The unique ID of each streaming session. |
region | String | The server area that has received the pushed stream. |
streamKey | String | The used streaming key. |
rtcInfo | Object | RTC information:
|
videoProfile | Object | Video properties. Not applicable for audio-only streams.
|
audioProfile | Object | Audio properties:
|
beginAt | String | The start time of the streaming in the RFC3339 format. |