This topic describes the trigger conditions for pulled-stream relay callbacks and provides the sample callbacks.
Events for pulled-stream relay callbacks
The events for pulled-stream relay callbacks include state changes of a pulled-stream relay task and exit of a pulled-stream relay task.
The following table describes the states of a pulled-stream relay task:
State | Description |
Idle | This is the initial state of a task that you create by calling the CreateLivePullToPush operation. |
Running | This is the state of a task that has automatically started after the specified start time, or that has been restarted after being stopped. |
Recovering | This is the state of a task that is retrying upon an exception during running. |
Offline | This is the state of a task that encounters an exception and fails to retry, or that you stop by calling the StopLivePullToPush operation. |
Exit | This is the state of a task that is automatically deleted after the specified end time, or that you delete by calling the DeleteLivePullToPush operation. |
Callbacks for state changes of a pulled-stream relay task
Description
When the state of a pulled-stream relay task changes to Running, Recovering, or Offline, a callback is invoked to indicate the state change.
Trigger conditions
When a task automatically starts at the specified start time or is restarted by calling the RestartLivePullToPush operation, the state of the task changes to
Running.When a task encounters an exception during running, the state of the task changes to
Recovering.When a task encounters an exception and fails to retry or is stopped by calling the StopLivePullToPush operation, the state of the task changes to
Offline.
Callbacks for exit of a pulled-stream relay task
Description
When a pulled-stream relay task is exited, a callback is invoked to indicate that the task has been cleared.
Trigger conditions
When a task is automatically deleted at the specified end time, the state of the task changes to
Exit.When a task is deleted by calling the DeleteLivePullToPush operation, the state of the task changes to
Exit.
Content of pulled-stream relay callbacks
The callback content in the JSON format is included in the request body of an HTTP POST request and sent to the callback URL. The server can parse the request body and obtain the callback content.
Parameters and example of a callback for state change of a pulled-stream relay task
Table 1. Parameters
Parameter
Description
Event
The event name. Fixed value:
LivePullToPushRunning.EventTime
The time when the event occurred. The value is a Unix timestamp in seconds.
TaskId
The task ID.
TaskInfo
The information about the task.
TaskStatus
The current state of the task. Valid values:
1: Running
2: Recovering
3: Offline
TaskInvalidReason
The reason why the task runs abnormally or stops running. Valid values:
PullStreamFailed: Stream pulling failed.PushStreamFailed: Stream relay failed.TriggerByUser: A corresponding API operation was called.UnknownError: An unknown error occurred.RetryTimesOffline: A timeout occurred.
NoteThis parameter is returned only when the state of the task is Offline.
Sample callback
{ "Event": "LivePullToPushRuning", "EventTime": "1725501246", "TaskId": "08a1b00c-9c2f-4dfa-9f5d-878f2505****", "TaskInfo": { "TaskId": "08a1b00c-9c2f-4dfa-9f5d-878f250****", "StartTime": "2024-09-05T01:54:00Z", "EndTime": "2024-09-05T01:58:00Z", "SourceUrls": [ "\"http://fyl-*******-*****.oss-cn-beijing.aliyuncs.com/record/caster/741584e2557248e98ef332d41e4afc3d/2024-08-30-18:19:40_2024-08-30-18:21:09.mp4\"" ], "DstUrl": "rtmp://pushtest.******.aliyunlive.com/pulltest38/pulltest-w38", "CallbackURL": "https://1833220977******.cn-shanghai.lc.aliyuncs.com/workflows/lc-uf6sd1382ikolc/triggers/manual/methods/invoke?ApiVersion=2018-12-12&Signature=TZT7CGDgc299cC2dtL73Yeq4xY8", "Offset": 0, "SourceType": "url" }, "TaskStatus": "1" }Parameters and example of a callback for exit of a pulled-stream relay task
Table 2. Parameters
Parameter
Description
Event
The event name. Fixed value:
LivePullToPushExit.EventTime
The time when the event occurred. The value is a Unix timestamp in seconds.
TaskId
The task ID.
TaskInfo
The information about the task.
TaskStatus
The current state of the task. Valid values:
-1: Exit
TaskExitTime
The time when the task was exited. The value is a Unix timestamp in seconds.
TaskExitReason
The reason why the task was exited.
TriggerByUser: A corresponding API operation was called.OverEndTime: The specified end time was reached.
Sample callback
{ "Event": "LivePullToPushExit", "EventTime": "1725501483", "TaskId": "08a1b00c-9c2f-4dfa-9f5d-878f2505****", "TaskInfo": { "TaskId": "08a1b00c-9c2f-4dfa-9f5d-878f2505****", "StartTime": "2024-09-05T01:54:00Z", "EndTime": "2024-09-05T01:58:00Z", "SourceUrls": [ "\"http://fyl-******-****.oss-cn-beijing.aliyuncs.com/record/caster/741584e2557248e98ef332d41e4afc3d/2024-08-30-18:19:40_2024-08-30-18:21:09.mp4\"" ], "DstUrl": "rtmp://pushtest.*****.aliyunlive.com/pulltest38/pulltest-w38", "CallbackURL": "https://1833220977******.cn-shanghai.lc.aliyuncs.com/workflows/lc-uf6sd1382ikolc/triggers/manual/methods/invoke?ApiVersion=2018-12-12&Signature=TZT7CGDgc299cC2dtL73Yeq4xY8", "Offset": 0, "SourceType": "url" }, "TaskStatus": "-1", "TaskExitTime": "1725501483", "TaskExitReason": "OverEndTime", }