what happens if the client tries to join a room us...
# ask-ai
c
what happens if the client tries to join a room using an access token which has expired?
t
Thanks for reaching out, Nathan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! If a client tries to join a room with an expired access token, the server won’t let them in. That’s because LiveKit uses JWT-based tokens that have an expiration time, so once they’re expired, they’re no longer valid. No worries though — the client just needs to grab a fresh, valid token before trying to join the room again. Sources: Authentication | LiveKit Docs | Authentication | LiveKit Docs | spec/livekit/token_verifier_spec.rb | livekit-api/tests/test_access_token.py | packages/livekit-server-sdk/src/AccessToken.ts
c
I've noticed that when my client tries to join a room with an expired token, it still allows them to join
t
Hey there! If your client can join a room even with an expired token, it’s probably because of LiveKit’s reconnection feature. Token expiration only matters when you first connect. After that, the server keeps the session going and refreshes tokens so you can reconnect smoothly if there’s a brief disconnect. But if this is happening right when you’re trying to connect for the first time, it might mean there’s a little hiccup in the setup or how token expiration is being handled. Just let me know if you want me to help you dig into it—I’m here for you! Sources: Authentication | LiveKit Docs | spec/livekit/token_verifier_spec.rb | livekit-api/tests/test_access_token.py | Authentication | LiveKit Docs
c
I'm using a ttl of 5 seconds just to test, and it's still letting the user into the room, even though it's been more than 5 seconds
t
Hey there! Just to clarify, LiveKit strictly enforces token expiration when you first connect. So, if your token has expired (like after 5 seconds in your test), the server should actually reject that connection attempt. But once you're already connected, the server can send refreshed tokens to keep your session going, which might be why it looks like the client joins successfully. If you’re seeing this happen right when you first try to connect, it could be a configuration hiccup or something off with how the token expiration is handled. Could you let me know if this is happening on the very first connection or when you’re trying to reconnect? I’m here to help you figure it out! Sources: Authentication | LiveKit Docs | spec/livekit/token_verifier_spec.rb | livekit-api/livekit/api/access_token.py
c
the client has not connected yet, and it still allows them
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!