mysterious-crayon-74973
05/14/2026, 9:17 AMtall-airline-16756
05/14/2026, 9:17 AMtall-airline-16756
05/14/2026, 9:18 AMroomService.deleteRoom() removes that room immediately and it is deleted. LiveKit does not automatically retry or recreate the room with the same name. If you want a room again you must call createRoom() (or otherwise create it) yourself.
Note: if you recreate a room with the same name very quickly, there’s a small chance the new room may reuse the previous Room ID due to timing in the system. To avoid any ambiguity, use a unique name (e.g., append a timestamp or UUID) when creating a new room.
Sources: Job lifecycle | LiveKit Documentation | Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name, with interactive elementsmysterious-crayon-74973
05/14/2026, 11:28 AMtall-airline-16756
05/14/2026, 11:28 AMdeleteRoom() is called, the room is terminated and removed. However, if your system (or clients) allow auto-creation on join (a createRoom-on-join flow), a subsequent join request can immediately create a new session with the same room name. That behavior is expected when join requests trigger room creation.
• There is also a race condition: if a join arrives right around the time deleteRoom() runs, the new room may be created immediately and could even reuse the previous Room ID due to timing. This is not a retry by LiveKit — it's a result of overlapping operations.
Recommendations to avoid unexpected recreation:
• Require explicit room creation (disable auto-create on join), or
• Use unique room names (append timestamp/UUID), or
• Coordinate deletion and joins (e.g., mark room as closed before deleting).
Which approach would you prefer or how do you currently create rooms on join?
, with interactive elementsmysterious-crayon-74973
05/14/2026, 11:32 AMtall-airline-16756
05/14/2026, 11:32 AMroomService.deleteRoom() terminates that room instance, but LiveKit will recreate a room if a new join request (or a token) for that room name arrives. This automatic create-on-join behavior is expected and not a LiveKit retry of the deleted room; it’s just that a join can trigger a new room instance (and, briefly after deletion, there can be race/timing that may reuse the previous Room ID).
To prevent automatic recreation, you can:
• Stop issuing or accept tokens that reference the deleted room name.
• Disable or avoid “create-on-join” logic in your app (require explicit createRoom() before allowing joins).
• Use unique room names per session (e.g., append timestamp or UUID).
• Add an app-level block: mark the room name as closed/deleted in your service and reject join attempts until you allow recreation.
Which option fits your setup best, or can you share how joins and tokens are currently issued so I can suggest a concrete change?
Sources: Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | CreateRoom() is Taking Too Long, with interactive elementsmysterious-crayon-74973
05/14/2026, 11:36 AMtall-airline-16756
05/14/2026, 11:37 AMif room_status(room_name) == "deleted":
raise Error("room is deleted")
# otherwise create token with `video.room` = room_name
2) Shorten token lifetime and avoid client reuse
• Issue tokens with short TTLs so stale tokens expire quickly.
• Clear client-side cached tokens when a room ends (localStorage/sessionStorage).
3) Revoke or rotate server secrets (if urgent)
• If tokens were already issued and could be reused before expiry, rotate the key that signs tokens to invalidate existing tokens immediately.
4) Add an application-level blocklist or gating
• Add a denylist of recently deleted room names and check it on join/token request.
• Optionally mark a room as “closed” before calling deleteRoom() to give your system time to stop issuing tokens.
5) (Optional) Use webhooks to sync state
• Use LiveKit webhooks (room_started/room_finished) to update your backend room status automatically so token issuance logic stays accurate.
If you share how tokens are currently generated (language/framework) or whether you use short TTLs or cached tokens on clients, I can give a specific code example for your stack.
Sources: Troubleshooting 401 Unauthorized and Token Errors | LiveKit | Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name, with interactive elementsmysterious-crayon-74973
05/14/2026, 11:51 AMcreateRoom() before allowing joins).
• Use unique room names per session (e.g., append timestamp or UUID).
• Add an app-level block: mark the room name as closed/deleted in your service and reject join attempts until you allow recreation.
why the react-agent-starter applicaiton is trying to rejoin in the deleted room ? how can we prevent from there ?tall-airline-16756
05/14/2026, 11:51 AMroomService.deleteRoom().
Short answer: the client is attempting to reconnect (or reuse a token) — not because LiveKit auto-retries deletion, but because the react-agent-starter Session/TokenSource logic is still trying to connect. To stop it, do one or more of the following:
• Call session.end() on the client when you delete the room. This stops the Session API’s reconnection attempts.
• Ensure the frontend clears any cached token and the room name from state/context after deletion (no localStorage/sessionStorage reuse).
• Add a server check in your token endpoint so it will refuse to issue tokens for that room name (denylist or room status check). If the client requests a token and the server rejects it, the client cannot rejoin.
• Add client-side guard in TokenSource (custom token provider) to throw if the room is marked deleted:
const tokenSource = TokenSource.custom(async (opts) => {
if (await isRoomDeleted(opts.roomName)) throw new Error("room deleted");
return fetchToken(opts);
});
• Optionally mark the room as “closed” in your app before calling deleteRoom() so your backend can stop issuing tokens immediately.
If you tell me where your token logic lives (which file/endpoint) or which reconnection path your client uses, I can give a concrete code change for react-agent-starter.
Sources: Build agent experiences faster with Session APIs | LiveKit | Avoiding Room ID Reuse When Re-Creating Rooms With the Same Name | Job lifecycle | LiveKit Documentation, with interactive elementsmysterious-crayon-74973
05/15/2026, 7:43 AMtall-airline-16756
05/15/2026, 7:43 AMroomService.disconnectParticipant() or the participant disconnect() method), LiveKit will terminate the room naturally after the idle timeout rather than treating it as an abrupt server-side termination. This avoids the client-style “network drop” reconnection loop you’re seeing with deleteRoom().
• Default idle timeout is short (around 30s); you can configure maxIdleTime if you want a different behavior for your deployment.
• Still do these on the client and server together:
◦ Call session.end() or otherwise stop reconnection attempts in the client when you initiate disconnects so it won’t try to rejoin.
◦ Stop issuing tokens for that room name (or check room state in your token endpoint) so stale client tokens can’t recreate the room.
When to prefer each method:
• Use participant disconnects → when you want a graceful end and to avoid client reconnect loops.
• Use deleteRoom() → when you need immediate termination and don’t mind coordinating token/client behavior to prevent recreation.
Want a small code snippet for disconnecting participants or for calling session.end() in react-agent-starter? Which language/file should I target?
, with interactive elementsmysterious-crayon-74973
05/15/2026, 8:48 AMtall-airline-16756
05/15/2026, 8:49 AMsession.end() (or stop the Session reconnection) immediately when you intend the session to be finished.
◦ Ensure the client clears any cached token and room name after ending the session.
• Prevent tokens for the deleted/closed room:
◦ On your token endpoint, check room state and refuse to issue tokens for deleted/closed room names (denylist or room status).
◦ Shorten token TTLs so stale tokens can’t be reused.
• Block auto-create-on-join:
◦ If your server supports it, return an error or do not provide create-on-join tokens. Alternatively, require explicit createRoom() on the server before allowing joins.
• Coordinated flow suggestion:
a. Mark room as “closing” in your backend.
b. Stop issuing tokens for that room.
c. Instruct clients to call session.end() and clear tokens.
d. Optionally call disconnectParticipant() for each participant, then deleteRoom() once clients are stopped.
• Optional: add a short denylist window (in-memory DB) for recently-deleted names to reject token requests for a few minutes after deletion.
Quick code hints
• Client: call session end
// react-agent-starter
session?.end(); // stops reconnect attempts
clearTokenFromStorage();
• Server: deny tokens for deleted rooms (pseudocode)
if (isRoomDeleted(roomName)) return 403;
return createToken(roomName);
If you want, tell me:
• where your token endpoint is implemented (language/file), and
• whether the client uses TokenSource.sandboxTokenServer or a custom TokenSource —
and I’ll give a precise code patch for that stack.
, with interactive elements