Skip to content

ListRooms() lies and you cannot rely on it. #639

@zt9

Description

@zt9

I’m seeing non-deterministic behavior where ListRooms often returns an empty list even though our webhook endpoint has already received every relevant event (room_started, participant_joined, and track_published) for that room.

I need a source of truth to let the connected clients know which the rooms are active and who's in it.

Without this, I am having to deal with keeping my own version of source of truth, dealing with out of order webhooks, clients that disappear, stale rooms etc. Would be nice to rely on livekit to give me the real state of affairs. (All this to say, please do not discount this request, it is important for a slew of things)

Reproduction Steps:

  1. Create a room via the Go SDK (CreateRoom succeeds).
  2. Verify your /livekit/webhook endpoint logs the following events:
    • room_started
    • participant_joined
    • track_published
  3. Immediately after, call RoomServiceClient.ListRooms.
  4. Observe that sometimes rooms is empty, despite all webhooks having arrived.

Expected Behavior:
ListRooms should always list any active room that has emitted a room_started webhook and subsequent participant/track events.


Relevant Logs:

2025-04-27T08:41:56-04:00 INF *** WEBHOOK: Received event: room_started for Room "lk_room_call_1745757715456802000"  
2025-04-27T08:41:58-04:00 INF *** WEBHOOK: Received event: participant_joined identity="alice-bot"  
2025-04-27T08:41:58-04:00 INF *** WEBHOOK: Received event: track_published identity="alice-bot"  
2025-04-27T08:41:58-04:00 INF --- ROOMS: Fetching active rooms from LiveKit...  
2025-04-27T08:41:58-04:00 INF ROOMS: No active rooms found in LiveKit.      ← unexpected empty result  

Environment:

  • Go SDK: server-sdk-go/v2
  • Hosted at wss://*.livekit.cloud
  • Authentication via API Key & Secret

Any insight into why ListRooms lags or misses these active rooms would be greatly appreciated!

Real Logs

{"level":"info","Who":"caller","time":"2025-04-27T08:41:56-04:00","message":"WEBSOCKET:  -- Received from Backend ⇽ JOIN_ROOM_INFO {\"callId\":\"call_1745757715456802000\",\"roomId\":\"lk_room_call_1745757715456802000\",\"liveKitToken\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDU3NjEzMTYsImlzcyI6IkFQSVFXUWJHcnVlfX0.Wv-PMoM4ro76xWLZLtqWQ0B2GC6gGU9jZjEuXEKbBI8\",\"liveKitUrl\":\"wss://cc-tqkxhzv2.livekit.cloud\"}\n"}
2025-04-27T08:41:56-04:00 INF *** WEBHOOK: Received event for Room: room_started, sid:"RM_vvXXgeTHQASC" name:"lk_room_call_1745757715456802000" empty_timeout:300 departure_timeout:20 creation_time:1745757716 creation_time_ms:1745757716621 enabled_codecs:{mime:"video/H264"} enabled_codecs:{mime:"video/VP8"} enabled_codecs:{mime:"video/VP9"} enabled_codecs:{mime:"video/AV1"} enabled_codecs:{mime:"audio/red"} enabled_codecs:{mime:"audio/opus"} version:{unix_micro:1745757716662917}, participant: <nil>
2025-04-27T08:41:56-04:00 INF --- ROOMS: Fetching active rooms from LiveKit...
2025-04-27T08:41:57-04:00 INF ROOMS: No active rooms found in LiveKit.
2025-04-27T08:41:57-04:00 INF BROADCAST: Sending 'ROOM_LIST_UPDATE' to all clients.
2025/04/27 08:41:58 "level"=0 "msg"="published track" "name"="" "source"="MICROPHONE" "trackID"="TR_AMNujpc9LNxXes"
2025-04-27T08:41:58-04:00 INF *** WEBHOOK: Received event for Room: participant_joined, sid:"RM_vvXXgeTHQASC" name:"lk_room_call_1745757715456802000" empty_timeout:300 departure_timeout:20 creation_time:1745757716 creation_time_ms:1745757716621 enabled_codecs:{mime:"video/H264"} enabled_codecs:{mime:"video/VP8"} enabled_codecs:{mime:"video/VP9"} enabled_codecs:{mime:"video/AV1"} enabled_codecs:{mime:"audio/red"} enabled_codecs:{mime:"audio/opus"} version:{unix_micro:1745757716662917}, participant: sid:"PA_YXoC7Nxkvyza" identity:"alice-bot" state:ACTIVE joined_at:1745757718 joined_at_ms:1745757718014 version:2 permission:{can_subscribe:true can_publish:true can_publish_data:true} region:"oashburn1a"
2025-04-27T08:41:58-04:00 INF --- ROOMS: Fetching active rooms from LiveKit...
2025-04-27T08:41:58-04:00 INF ROOMS: No active rooms found in LiveKit.
2025-04-27T08:41:58-04:00 INF BROADCAST: Sending 'ROOM_LIST_UPDATE' to all clients.
2025-04-27T08:41:58-04:00 INF *** WEBHOOK: Received event for Room: track_published, sid:"RM_vvXXgeTHQASC" name:"lk_room_call_1745757715456802000", participant: sid:"PA_YXoC7Nxkvyza" identity:"alice-bot"
2025/04/27 08:41:58 "level"=0 "msg"="published track" "name"="" "source"="MICROPHONE" "trackID"="TR_AMggfeaZe739Et"
starting waitCounts
{"level":"info","time":"2025-04-27T08:41:58-04:00","message":"WEBSOCKET: Received from Backend ⇽ ROOM_LIST_UPDATE []\n"}
{"level":"info","time":"2025-04-27T08:41:58-04:00","message":"WEBSOCKET: Received from Backend ⇽ ROOM_LIST_UPDATE []\n"}
{"level":"info","time":"2025-04-27T08:41:58-04:00","message":"WEBSOCKET: Received from Backend ⇽ ROOM_LIST_UPDATE []\n"}
{"level":"info","time":"2025-04-27T08:41:58-04:00","message":"WEBSOCKET: Received from Backend ⇽ ROOM_LIST_UPDATE []\n"}
2025/04/27 08:41:58 "level"=0 "msg"="track subscribed" "participant"="alice-bot" "track"="TR_AMNujpc9LNxXes" "kind"="audio"
2025-04-27T08:41:58-04:00 INF *** WEBHOOK: Received event for Room: track_published, sid:"RM_vvXXgeTHQASC" name:"lk_room_call_1745757715456802000", participant: sid:"PA_J2RPusRR47kk" identity:"bob-bot"
2025-04-27T08:41:58-04:00 INF *** WEBHOOK: Received event for Room: participant_joined, sid:"RM_vvXXgeTHQASC" name:"lk_room_call_1745757715456802000" empty_timeout:300 departure_timeout:20 creation_time:1745757716 creation_time_ms:1745757716621 enabled_codecs:{mime:"video/H264"} enabled_codecs:{mime:"video/VP8"} enabled_codecs:{mime:"video/VP9"} enabled_codecs:{mime:"video/AV1"} enabled_codecs:{mime:"audio/red"} enabled_codecs:{mime:"audio/opus"} version:{unix_micro:1745757716662917}, participant: sid:"PA_J2RPusRR47kk" identity:"bob-bot" state:ACTIVE tracks:{sid:"TR_AMggfeaZe739Et" source:MICROPHONE mime_type:"audio/opus" mid:"1" stream:"camera" version:{unix_micro:1745757718460685}} joined_at:1745757718 joined_at_ms:1745757718194 version:3 permission:{can_subscribe:true can_publish:true can_publish_data:true} region:"oashburn1a" is_publisher:true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions