clean-wolf-63214
06/26/2025, 7:53 PM{"message": "livekit::rtc_engine:450:livekit::rtc_engine - received session close: \"server request to leave\" ConnectionTimeout Resume", "level": "WARNING", "name": "livekit", "call_id": "2cd793e2-a389-4c9b-8c75-32f7548e8fe0", "tenant_id": "93a14ff5-258d-4d77-a9c0-aa498a5d094a", "pid": 34746, "job_id": "AJ_T8mPUuhZDqDq", "timestamp": "2025-06-24T21:44:14.164188+00:00"}
develop-voice-agent
2025-06-24T21:44:14.165Z
{"message": "livekit::rtc_engine:450:livekit::rtc_engine - received session close: \"signal client closed: \\\"stream closed\\\"\" UnknownReason Resume", "level": "WARNING", "name": "livekit", "call_id": "2cd793e2-a389-4c9b-8c75-32f7548e8fe0", "tenant_id": "93a14ff5-258d-4d77-a9c0-aa498a5d094a", "pid": 34746, "job_id": "AJ_T8mPUuhZDqDq", "timestamp": "2025-06-24T21:44:14.164315+00:00"}
develop-voice-agent
2025-06-24T21:44:14.084Z
{"message": "livekit::rtc_engine:450:livekit::rtc_engine - received session close: \"signal client closed: \\\"stream closed\\\"\" UnknownReason Resume", "level": "WARNING", "name": "livekit", "call_id": "2cd793e2-a389-4c9b-8c75-32f7548e8fe0", "tenant_id": "93a14ff5-258d-4d77-a9c0-aa498a5d094a", "pid": 34746, "job_id": "AJ_T8mPUuhZDqDq", "timestamp": "2025-06-24T21:44:14.084484+00:00"}
develop-voice-agent
2025-06-24T21:44:14.083Z
{"message": "livekit::rtc_engine::rtc_session:743:livekit::rtc_engine::rtc_session - Publisher pc state failed", "level": "ERROR", "name": "livekit", "call_id": "2cd793e2-a389-4c9b-8c75-32f7548e8fe0", "tenant_id": "93a14ff5-258d-4d77-a9c0-aa498a5d094a", "pid": 34746, "job_id": "AJ_T8mPUuhZDqDq", "timestamp": "2025-06-24T21:44:14.082083+00:00"}
develop-voice-agent
2025-06-24T21:44:14.083Z
{"message": "livekit::rtc_engine:450:livekit::rtc_engine - received session close: \"pc_state failed\" UnknownReason Resume", "level": "WARNING", "name": "livekit", "call_id": "2cd793e2-a389-4c9b-8c75-32f7548e8fe0", "tenant_id": "93a14ff5-258d-4d77-a9c0-aa498a5d094a", "pid": 34746, "job_id": "AJ_T8mPUuhZDqDq", "timestamp": "2025-06-24T21:44:14.083068+00:00"}
1. What causes these to happen?
2. We created a room.on("disconnected")
listener and we are not sure how to reproduce/test this listener. Any thoughts?tall-airline-16756
06/26/2025, 7:53 PMtall-airline-16756
06/26/2025, 7:54 PMroom.on("disconnected")
listener, you can simulate disconnection scenarios. For instance, you can manually call room.disconnect()
in your code to trigger the listener. Additionally, you can test by intentionally causing conditions like duplicate identities or removing a participant via the API. Here's an example of setting up the listener:
// First connect to the room
const room = new Room();
await room.connect(wsUrl, token);
// Set up the disconnected event listener
room.on('disconnected', (reason) => {
console.log('Disconnected from room with reason:', reason);
// Handle the disconnection based on the reason
});
This listener will capture and log the disconnection reason, allowing you to handle it appropriately.
Sources: Connecting to LiveKit | LiveKit Docs | livekit.rtc API documentation | RoomEvent | LiveKit JS Client SDK - v2.8.1clean-wolf-63214
06/26/2025, 8:47 PM@self._ctx.room.on("disconnected")
def on_room_disconnected(reason: rtc.DisconnectReason):
logger.error(
f"DISCONNECT HANDLER TRIGGERED - Room disconnected with reason: {reason} (type: {type(reason)})"
)
logger.error(
f"Call {self._call_id} - Current status: {self._current_status.value}, Is terminal: {self._is_terminal}"
)
asyncio.create_task(self._transition_to_terminal_state(CallStatus.FAILED))
when i run
await ctx.agent.disconnect() somewhere in the execution, i don't see any of the logs from the listener printedtall-airline-16756
06/26/2025, 8:48 PMroom.on("disconnected")
listener might not be working as expected. There are a few friendly things we can check together: 1. Listener Registration: Double-check that you've set up your listener before the disconnection happens. It's like making sure you've got your mic ready before a video call! 2. Logging Configuration: Make sure your logging settings are catching the right level of messages. Think of it like adjusting the volume – you want to hear what's important. 3. Event Emission: Let's confirm the disconnect()
method is actually sending out that disconnected event. A quick print statement can be your best friend here. 4. Asynchronous Context: When you're using asyncio.create_task
, just make sure your event loop isn't getting stuck somewhere else in your code. Here's a handy debugging approach you can try: python @self._ctx.room.on("disconnected") def on_room_disconnected(reason: rtc.DisconnectReason): print("Listener triggered") # Debugging print statement logger.error( f"DISCONNECT HANDLER TRIGGERED - Room disconnected with reason: {reason} (type: {type(reason)})" ) asyncio.create_task(self._transition_to_terminal_state(CallStatus.FAILED))
If the print statement doesn't show up, we might have an issue with how the listener is registered or how the event is being emitted. If it does appear but the logs are playing hide and seek, let's take a peek at your logging configuration. Hope this helps you track down the issue! Debugging can be a bit like detective work – we'll solve this together. 🕵️♀️🔍 Sources: GitHub::livekit::agents | livekit-agents/livekit/agents/voice/room_io/room_...clean-wolf-63214
06/26/2025, 8:52 PMtall-airline-16756
06/26/2025, 8:52 PM_on_room_event
could totally be a smart way to handle disconnection events! I've got some insights that might help you navigate this. Think of _on_room_event
like a behind-the-scenes detective tracking what's happening in your room. When a participant disconnects, this method does some really helpful things: 1. It finds out who just left the room 2. Removes that participant from your participants list 3. Notes down why they disconnected 4. Sends out a friendly notification about the disconnection If you're wondering whether to use this method or the standard room.on("disconnected")
listener, here's the scoop: _on_room_event
gives you more detailed control. It's like having a backstage pass to see exactly what's happening. Here's a peek at how you might use it:
def _on_room_event(self, event: proto_room.RoomEvent):
which = event.WhichOneof("message")
if which == "participant_disconnected":
identity = event.participant_disconnected.participant_identity
rparticipant = self._remote_participants.pop(identity)
rparticipant._info.disconnect_reason = event.participant_disconnected.disconnect_reason
self.emit("participant_disconnected", rparticipant)
And here's a cool way to handle those disconnections:
room.on(
"participant_disconnected",
lambda p: asyncio.create_task(handle_disconnect(p)),
)
Just make sure this approach fits nicely with how your app is set up. Every project is a bit different, right? 😊 Let me know if you want to chat more about handling these disconnections! Sources: livekit.rtc API documentation | GitHub::livekit::agents | livekit-agents/livekit/agents/voice/room_io/room_...clean-wolf-63214
06/26/2025, 8:57 PMtall-airline-16756
06/26/2025, 8:57 PMroom.on("disconnected")
listener is your best friend. Think of it like a safety net for your connection. The _on_room_event
method is more for catching individual participant disconnects, so let's keep our focus where it counts. To make sure everything's working smoothly, here are a few friendly checkpoints: 1. Listener Registration: Just like making sure you've got your keys before leaving home, double-check that your listener is set up before any potential disconnects. 2. Event Emission: Add a quick print statement or debug log. It's like leaving a breadcrumb to see exactly what's happening. 3. Logging Configuration: Take a peek at your logging setup and make sure you're capturing the right log levels. Here's a handy example that might help you out:
@self._ctx.room.on("disconnected")
def on_room_disconnected(reason: rtc.DisconnectReason):
print("Room disconnected with reason:", reason) # Debugging print statement
logger.error(
f"DISCONNECT HANDLER TRIGGERED - Room disconnected with reason: {reason} (type: {type(reason)})"
)
asyncio.create_task(self._transition_to_terminal_state(CallStatus.FAILED))
If things still aren't clicking, don't stress! It might just be a small SDK hiccup or something unique to your setup. I'm here to help you troubleshoot and get things running smoothly. Shoot me any questions you've got, and we'll figure this out together! 😊