logo
Video Call
Server API
Stream Mixing and Transcoding APIs
On this page

Stream Destroyed Callback


Warning

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。
Note

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 parametersTypeDescription
eventStringCallback event, this callback returns stream_close.
appidStringAppId.
timestampStringServer current time, Unix timestamp.
nonceStringRandom number.
signatureStringVerification string, please refer to Callback instructions - Verification instructions.
Business parametersTypeDescription
room_idStringRoom ID, corresponds to the client's RoomID, has the same meaning as channel_id, not exceeding 127 bytes.
room_session_idStringUnique identifier of the Room lifecycle, remains unchanged during the entire lifecycle of the Room.
user_idStringUser ID, not exceeding 255 bytes.
user_nameStringUser nickname, not exceeding 255 bytes.
channel_idStringChannel ID, corresponds to the client's RoomID, not exceeding 127 bytes.
typeStringClose type.
  • 0: Normal close (User calls the SDK's stopPublishingStream interface to stop Publishing stream).
  • Non 0 is abnormal close:
    • 1: User heartbeat timeout close.
    • 2: User repeatedly logged in to the same Room, closing the Stream from the previous login session.
    • 3: Server interface kickout user, closing the Stream created by the user.
    • 4: tcp disconnect closes Stream (configurable notification time).
    • 5: Room was cleared and Stream was closed.
    • 100: Call the server interface DeleteStream to close Stream.
stream_aliasStringStream name, corresponds to the client's StreamID, not exceeding 255 bytes.
stream_idStringStream ID, corresponds to the client's StreamID, has the same meaning as stream_alias.
stream_sidStringStream server ID, the unique identifier of the Stream, generated by ZEGOCLOUD backend, developers do not need to pay attention.
stream_seqStringThe seq of the server Stream list change, increments by 1 each time the Stream changes.
third_define_dataStringCustomer-defined data.
create_time_msStringStream creation time, server current time, Unix timestamp. Unit: milliseconds.
destroy_timemillisStringStream close time, server current time, Unix timestamp. Unit: milliseconds.
Note

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.

Previous

Stream Created Callback

Next

Stream Mixing Started Callback

On this page

Back to top