-
Notifications
You must be signed in to change notification settings - Fork 136
Description
Describe the bug
Calling Room.connect() on a room that is not in DISCONNECTED state throws an unrecoverable IllegalStateException, crashing the app. This can happen in legitimate reconnection scenarios where the server instructs the client to reconnect after a
network disruption. The SDK should handle this gracefully (e.g. by disconnecting first, queuing the connect, or returning an error) rather than throwing a fatal exception that crashes the host application.
java.lang.IllegalStateException: Room.connect attempted while room is not disconnected!
at io.livekit.android.room.Room$connect$2.invokeSuspend(Room.kt:389)
To Reproduce
- Connect to a LiveKit room successfully
- Trigger a network disconnection (e.g. airplane mode)
- Wait for the room to transition away from CONNECTED state
- Restore network and call Room.connect() again on the same room instance before it has fully transitioned to DISCONNECTED
- App crashes with IllegalStateException
Expected behavior
Room.connect() should not crash the application. If called on a non-disconnected room, it should either:
- Disconnect the current session first and then proceed with the new connection, or
- Return a meaningful error/exception that the caller can catch and handle, or
- No-op if already connecting with the same parameters