Stream Destroyed Callback
Stopping Stream Mixing will not trigger this callback. For Stream Mixing related callbacks, please refer to Stream Mixing Stopped Callback.
Description
When developers need to maintain a live list, when the APP has a Stream closed on the streaming media server, it will make a POST request to the callback URL.
Callback instructions
- Request method: POST。
The callback data format is JSON, you need to decode it with UrlDecode.
- Request URL: Please configure the callback URL in the ZEGOCLOUD console.
- Transfer protocol: HTTPS/HTTP, HTTPS is recommended.
Callback parameters
| Common parameters | Type | Description |
|---|---|---|
| event | String | Callback event, this callback returns stream_close. |
| appid | String | AppId. |
| timestamp | String | Server current time, Unix timestamp. |
| nonce | String | Random number. |
| signature | String | Verification string, please refer to Callback instructions - Verification instructions. |
| Business parameters | Type | Description |
| room_id | String | Room ID, corresponds to the client's RoomID, has the same meaning as channel_id, not exceeding 127 bytes. |
| room_session_id | String | Unique identifier of the Room lifecycle, remains unchanged during the entire lifecycle of the Room. |
| user_id | String | User ID, not exceeding 255 bytes. |
| user_name | String | User nickname, not exceeding 255 bytes. |
| channel_id | String | Channel ID, corresponds to the client's RoomID, not exceeding 127 bytes. |
| type | String | Close type.
|
| stream_alias | String | Stream name, corresponds to the client's StreamID, not exceeding 255 bytes. |
| stream_id | String | Stream ID, corresponds to the client's StreamID, has the same meaning as stream_alias. |
| stream_sid | String | Stream server ID, the unique identifier of the Stream, generated by ZEGOCLOUD backend, developers do not need to pay attention. |
| stream_seq | String | The seq of the server Stream list change, increments by 1 each time the Stream changes. |
| third_define_data | String | Customer-defined data. |
| create_time_ms | String | Stream creation time, server current time, Unix timestamp. Unit: milliseconds. |
| destroy_timemillis | String | Stream close time, server current time, Unix timestamp. Unit: milliseconds. |
It is recommended to convert some parameters to Int for logical processing. Related fields include type, destroy_timemillis, stream_seq, create_time_ms, room_session_id.
Data example
{
"event": "stream_close",
"appid": "1",
"timestamp": "1666786067",
"nonce": "7266888922840654370",
"signature": "xxx",
"room_id": "room1",
"room_session_id": "123456789",
"user_id": "user1",
"user_name": "user1_name",
"channel_id": "0xb-0x1",
"type": "0",
"stream_alias": "aaa",
"stream_id": "stream_id",
"stream_sid": "s-115205136669740000000000104",
"stream_seq": "700",
"third_define_data": "{\"u\":\"S1lxOUxMN2tRZ3lIY0JMSUs3VlMxZz09\"}",
"create_time_ms": "1666786067353",
"destroy_timemillis": "1666986067248"
}Return response
Returning HTTP status code 2XX (e.g. 200) indicates success, other responses indicate failure.
Callback retry strategy
If ZEGOCLOUD server does not receive a response, or the received HTTP status code is not 2XX (e.g. 200), it will try to retry, up to 5 retries. The interval between each retry request and the previous request is 2s, 4s, 8s, 16s, 32s respectively. If the 5th retry still fails, no more retries will be made and the callback will be lost.
