Stop reconnect if local participant was removed by the server
sparrowhe opened this issue · 4 comments
Describe the problem
I found the client will try to reconnect to the server even they was kicked.
Describe the proposed solution
I think the better way is stop try to reconnect. If a user has been kicked, the sdk should not reconnect to server without call Room.connect() method.
Alternatives considered
Provide a way to stop reconnect event. (like a Pre-Action?)
Importance
nice to have
Additional Information
No response
which server and client version are you running?
And how are you "kicking" the user?
There should be no reconnects happening when explicitly removing a participant via server APIs.
which server and client version are you running? And how are you "kicking" the user? There should be no reconnects happening when explicitly removing a participant via server APIs.
"livekit-client": "^2.3.2"
and server version 1.7, using Java Server SDK, removeParticipant to kick user.
Actually, I can receive disconnect event with reason PARTICIPANT_REMOVED and after few seconds, the SDK reconnected to the server.
I'm using a custom reconnect policy to ensure it will not reconnect when the last reason is removed,
class CustomReconnectPolicy implements ReconnectPolicy {
private readonly _retryDelays: number[];
constructor(retryDelays?: number[]) {
this._retryDelays = retryDelays !== undefined ? [...retryDelays] : DEFAULT_RETRY_DELAYS_IN_MS;
}
public nextRetryDelayInMs(context: ReconnectContext): number | null {
if (globalReason == LiveKit.DisconnectReason.PARTICIPANT_REMOVED) return null;
if (context.retryCount >= this._retryDelays.length) return null;
const retryDelay = this._retryDelays[context.retryCount];
if (context.retryCount <= 1) return retryDelay;
return retryDelay + Math.random() * 1_000;
}
}
Hm. The client does not attempt to reconnect in my testing, even with the default reconnect policy.
Please provide full debug logs of such a session (with default reconnect policy).
closing this due to inactivity