Hi LiveKit Team,
One of my users experienced an issue where the interview session was suddenly closed during an ongoing interview. In the browser console, I observed the following error:
error in room ConnectionError: could not establish signal connection: invalid token
at nc. (6295.dd10fa3c.chunk.js:1:417095)
at Generator.next ()
at a (6295.dd10fa3c.chunk.js:1:120778)
Could you please help me understand the possible reasons for this error and how to prevent it? This is very critical for us since interviews should not be interrupted once they start.
Room Id : RM_Z2UGUdvv7E9y
Perhaps an expired token? There are some troubleshooting steps in this guide: Troubleshooting 401 Unauthorized and Token Errors | LiveKit
Could this be the issue?
Currently I am generating the token like this:
const at = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET, {
identity: participantName,
name: participantName,
ttl: 5 * 60
});
I set the TTL to only 5 minutes, but my interviews sometimes last longer (10 minutes, 25 minutes, or even 60 minutes).
I am planning to change the code to the following. Could you please confirm if this approach is correct?
const at = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET, {
identity: participantName,
name: participantName,
ttl: duration * 60 + 300 // interview duration in minutes converted to seconds + 5 minutes buffer
});
The token only needs to be valid for the initial join, you don’t need to set the TTL to cover the entire expected duration of the call. Client reconnects should be handled automatically by refreshed tokens: Tokens & grants | LiveKit Documentation
If you look at the events for the room (the link you shared above), it says the participant left with CONNECTION_TIMEOUT, I wonder if the participant left for whatever reason (network?) and then tried to join at a later time after the room was closed, which resulted in the token errors.
Should I change the logic to: Do not delete the room when a participant leaves,
but delete it if they did not re-join within 1 minute?
If yes, how can I do that?
Yes, that will work. You can set the departure_timeout on the Room options: Room service API | LiveKit Documentation
If you are creating the room manually, you can set it on CreateRoom: Room service API | LiveKit Documentation
If you are creating the room automatically, you can set it on the participant’s token: Tokens & grants | LiveKit Documentation
1 Like