Reconnection and kick policy
Automatic reconnection
After a successful connection, the nexconn SDK automatically manages reconnection: it retries when the network fluctuates and continues reconnecting after the network recovers.
Common scenarios that trigger reconnection:
- Weak network: May cause continuous reconnection attempts.
- No network: Reconnection pauses and resumes after network recovery.
When an unrecoverable error occurs (for example, TOKEN_INCORRECT), your application must handle it and initiate a new connection.
Reconnection intervals
The SDK gradually increases reconnection intervals (short intervals first, then longer intervals). When the network switches or the app returns to the foreground, the SDK resets to short intervals to restore the connection quickly.
Exit reconnection
After you call NCChatUI.disconnect() or NCChatUI.logout(), the current connection exits automatic reconnection.
Reconnection kick policy
The reconnection kick policy controls which device remains online when a reconnecting device and an already-online device conflict.
Configure the policy with ConnectParams.reconnectKickEnable:
false(default): The reconnecting device kicks the already-online device offline.true: The reconnecting device is kicked offline, and the already-online device remains connected.
- Kotlin
- Java
val params = ConnectParams(token).apply {
reconnectKickEnable = true
}
NCChatUI.connect(params) { userId, error ->
// Connection result
}
ConnectParams params = new ConnectParams(token);
params.setReconnectKickEnable(true);
NCChatUI.connect(params, (userId, error) -> {
// Connection result
});