Summary
In the manual_start_stop_using_python/rtms.py example, the connect_to_signaling_websocket coroutine awaits the call to connect_to_media_websocket inside the signaling message loop (see around line 156). This effectively blocks the signaling loop on the media WebSocket. As a result, the signaling socket cannot respond to keep‑alive messages while the media socket is open.
Details
- At line 156,
schedule_rtms_stop is invoked to stop the RTMS after 10 seconds.
- Within
connect_to_signaling_websocket, the async for‑loop awaits connect_to_media_websocket when a successful handshake is received. This call does not return until the media WebSocket closes, which prevents the signaling loop from handling keep‑alive messages (msg_type == 12) in a timely manner.
- In a production implementation, establishing the media WebSocket should run concurrently (e.g., via
asyncio.create_task or launching a new thread) so that the signaling socket can continue processing messages.
Request
Could we update the example to reflect this behaviour? Perhaps either:
- Add a comment explaining that developers should spawn
connect_to_media_websocket as a task or thread rather than awaiting it directly; or
- Modify the sample code to use
asyncio.create_task(connect_to_media_websocket(...)) to avoid blocking the signaling socket.
Summary
In the
manual_start_stop_using_python/rtms.pyexample, theconnect_to_signaling_websocketcoroutine awaits the call toconnect_to_media_websocketinside the signaling message loop (see around line 156). This effectively blocks the signaling loop on the media WebSocket. As a result, the signaling socket cannot respond to keep‑alive messages while the media socket is open.Details
schedule_rtms_stopis invoked to stop the RTMS after 10 seconds.connect_to_signaling_websocket, the async for‑loop awaitsconnect_to_media_websocketwhen a successful handshake is received. This call does not return until the media WebSocket closes, which prevents the signaling loop from handling keep‑alive messages (msg_type == 12) in a timely manner.asyncio.create_taskor launching a new thread) so that the signaling socket can continue processing messages.Request
Could we update the example to reflect this behaviour? Perhaps either:
connect_to_media_websocketas a task or thread rather than awaiting it directly; orasyncio.create_task(connect_to_media_websocket(...))to avoid blocking the signaling socket.