Could you please confirm if this is a guaranteed behavior?
As I mentioned in the topic you referred:
ConnectionState.Fail: This is a terminal state—reconnection failed.
ConnectionState.Reconnecting: If reconnection succeeds, a subsequent ConnectionState.Connected event will be emitted.
ConnectionState.Fail is only returned when reconnection fails. If the network condition is poor and there is still no network during the reconnection attempt, it will result in a failed reconnection, triggering ConnectionState.Fail.
Hi @vic.yang ,
Sorry to trouble you again, and thank you for your previous support.
We have a few more questions regarding the SDK’s connection behavior:
Since the SDK automatically attempts to reconnect after emitting ConnectionState.Reconnecting, is it correct that the app only needs to handle Connected and Fail (e.g., trigger manual rejoin only after receiving Fail)?
If the app calls join() manually during this reconnecting state, will the SDK cancel its internal reconnect attempt?
If the SDK has almost finished reconnecting internally, but the app calls join() just before it emits Connected:
– Will it result in join() failure?
– If so, will ConnectionState.Connected still be emitted afterward?
is it correct that the app only needs to handle Connected and Fail (e.g., trigger manual rejoin only after receiving Fail )?
Yes.
However, we recommend displaying a ‘reconnecting’ prompt to the user when ConnectionState.Reconnecting is received, because during this period, audio and video functionalities are unavailable.
If the app calls join() manually during this reconnecting state, will the SDK cancel its internal reconnect attempt?
No
If the SDK has almost finished reconnecting internally, but the app calls join() just before it emits Connected:
– Will it result in join() failure?
Yes. It will return a rejected promise with ExceptionCode.CLIENT_DUPLICATED_JOIN and the reason ‘duplicated operation’.
– If so, will ConnectionState.Connected still be emitted afterward?
Yes.
In short, when the connection-change event indicates ConnectionState.Reconnecting, you should not call the join method again, as it may lead to unexpected exceptions.