livekit / client-sdk-android

LiveKit SDK for Android
https://docs.livekit.io
Apache License 2.0
185 stars 76 forks source link

Unable to Connect to Different LiveKit Session After Disconnecting Using Same Room Instance #237

Open Pflanzmann opened 1 year ago

Pflanzmann commented 1 year ago

Describe the bug

An issue is occurring when using LiveKit.create(context) to create a room, applying ReconnectType.FORCE_FULL_RECONNECT, and injecting this room into our manager.

The bug manifests when disconnecting from the room after a prior connection, where we are unable to connect to a different LiveKit session using the same room instance. This is excepted when attempting to reconnect the room after a delay of a few seconds. The event stream of the room delivers a "Disconnected" event with a null error and a "CLIENT_INITIATED" reason when we attempt to connect to a new session for the first time after the disconnection.

LiveKit.create(context).apply {
  setReconnectionType(ReconnectType.FORCE_FULL_RECONNECT)
}

Steps to Reproduce

  1. Create a room instance using the code above.
  2. Connect to a LiveKit session.
  3. Disconnect from that session.
  4. Attempt to connect to a different LiveKit session using the same room instance.

Expected Behavior

The expected behavior is to successfully connect to the different LiveKit session using the same room instance.

Device Info:

Additional Context

This issue seems similar to a previously reported bug that has been closed. As the problem still persists, I've opened this new issue.

As a temporary workaround, creating a new room instance for each new connection is possible, but this solution seems inefficient and doesn't align well with our project's architecture. Any assistance in addressing this issue would be greatly appreciated.


davidliu commented 1 year ago

ReconnectType.FORCE_FULL_RECONNECT is only there as a debug option for our own testing purposes; it's not intended to be used in production (it makes the reconnection process to a server more inefficient).

Does this issue still happen without the setReconnectType call?

Pflanzmann commented 1 year ago

Ive tried it without ReconnectType.FORCE_FULL_RECONNECT and I can still not connect and get a CLIENT_INITIATED reason in the disconnect event