Real-time Action Output Streaming : Immediate Connection Close


(Pon Malar) #1

Hi Team,

GET /v1/executions//output

We found the documentation in version 2.9 and 2.7 respectively.

Version 2.9 “This API endpoint returns data produced by the execution so far and closes the connection. If the execution has already completed, it will return all data produced by that execution.”

Version 2.7 : The API endpoints keep a long running connection open until the execution completes or the user closes the connection.

Once requested, the API endpoint returns any data which has been produced so far and after that, any new data as it becomes available.

Question: Does the API endpoints return the data and closes the connection automatically.

In the version 2.9.1, it immediately closes the connection.


(Tomaz Muraus) #2

We have changed that behavior in v2.9.0 to better account for differences between the streaming and non-streaming API (long lived vs short lived connections).

From the changelog:

  • Change GET /v1/executions/<id>/output API endpoint so it never blocks and returns data produced so far for running executions. Behavior for completed executions is the same and didn’t change - all data produced by the execution is returned in the raw format.

    The streaming (block until execution has finished for running executions) behavior has been moved to the new /stream/v1/executions/<id>/output API endpoint.

    This way we are not mixing non-streaming (short lived) and streaming (long lived) connections inside a single service (st2api). (improvement)

If you want blocking behavior you need to utilize the stream API endpoint (/stream/v1/executions/<id>/output).

Also keep in mind that both of those API endpoints only support non-workflow executions (if you use workflow execution ID it won’t return any data).

If you want to tail all the child executions in a workflow, you need to implement a similar logic to the one implemented by the st2 execution tail CLI command (it utilizes the event stream API endpoint and automatically follows and tails child executions for workflows).