bright-plumber-93445
05/08/2025, 10:30 AMtall-airline-16756
05/08/2025, 10:30 AMtall-airline-16756
05/08/2025, 10:30 AM@ctx.room.on("disconnected")
event in LiveKit, you can utilize the Disconnected
event's reason property. This property provides details about why the disconnection occurred, such as:
• DUPLICATE_IDENTITY: Another participant with the same identity joined the room.
• ROOM_DELETED: The room was closed via the DeleteRoom
API.
• PARTICIPANT_REMOVED: The participant was removed using the RemoveParticipant
API.
• JOIN_FAILURE: Connection to the room failed, possibly due to network issues.
• ROOM_CLOSED: The room was closed because all participants left.
By accessing the reason
property in the event handler, you can log this information for debugging or monitoring purposes.
Sources: Connecting to LiveKit | LiveKit Docs | Disconnectedbright-plumber-93445
05/08/2025, 10:30 AMtall-airline-16756
05/08/2025, 10:30 AM@ctx.room.on("disconnected")
event in LiveKit:
import logging
async def entrypoint(ctx):
# Connect to the room
await ctx.connect()
@ctx.room.on("disconnected")
def on_room_disconnected(event):
<http://logging.info|logging.info>("Room disconnected, reason: %s", event.reason)
# Log if there was an error
if event.error:
logging.error("Disconnect error: %s", event.error)
# Rest of your code...
This example sets up an event handler for the "disconnected"
event on the room object, which logs the reason for disconnection and any associated error.
Sources: Tree View: | dse-workbenchbright-plumber-93445
05/08/2025, 10:36 AMtall-airline-16756
05/08/2025, 10:36 AMbright-plumber-93445
05/08/2025, 11:06 AM