enough-match-43171
12/16/2025, 12:20 PMtall-airline-16756
12/16/2025, 12:20 PMtall-airline-16756
12/16/2025, 12:20 PMawait lkapi.aclose() right after starting egress, and how/when recording stops. Good questions — here's the concise answer.
• Why await lkapi.aclose() is called: that closes the local HTTP client used by LiveKitAPI. Once you've started the egress with start_room_composite_egress, the recording runs on the LiveKit server independently, so you can safely close the local client to release resources.
• When recording stops: room composite egress is tied to the room lifecycle — it stops automatically when the room ends (for example, when all participants leave).
• If you need to stop earlier: call the Stop Egress API with the egress ID:
await lkapi.egress.stop_egress(egress_id="your-egress-id")
Would you like an example showing how to capture the egress_id from the start response and stop it later?
Sources: Observability data hooks | LiveKit docs | RoomComposite Egress | LiveKit Docs | Egress examples | LiveKit docsenough-match-43171
12/16/2025, 1:42 PMtall-airline-16756
12/16/2025, 1:42 PMLiveKitAPI client (call await lkapi.aclose()) to release HTTP resources.
When you should explicitly stop egress in shutdown:
• Your process is shutting down and you need the recording to end immediately (rather than waiting for the room to end).
• You want to finalize outputs (e.g., ensure upload completion) or transition to post-processing right away.
• You need deterministic egress lifecycle for billing, orchestration, or automation reasons.
How to do it:
1. Capture the start response which includes the egress_id.
2. In your shutdown callback call:
await lkapi.egress.stop_egress(egress_id="the-egress-id")
await lkapi.aclose()
If you’d like, I can show a short example illustrating capturing egress_id and wiring it into a shutdown handler.