Network Disruptions

Connection problems can occur during a call, for example when switching networks or if the signal is poor. In this case the SDK will try to reconnect automatically.

The call.setDisconnectionTimeout method allows you to specify how long a user can remain disconnected before being removed from the call. This is particularly useful when users experience short network interruptions and are able to reconnect quickly. By setting a timeout you ensure that users are only dropped if their disconnection lasts longer than the specified time.

Setting the disconnection timeout

Once the call has been created, you can set a disconnection timeout that defines how long a user can stay disconnected before being dropped. Here’s how to do it:

call.setDisconnectionTimeout(30); // Try to reconnect for 30 seconds
call.setDisconnectionTimeout(0); // try to reconnect indefinitely (default)

By default the disconnection timeout is set to 0, allowing the user to remain in the call until their connection restores or the call is ended.

Notify user after disconnection

Current reconnection state is reflected in the calling state.

After a specified timeout, if the connection is not reestablished, the calling state becomes CallingState.RECONNECTING_FAILED. We can subscribe to it to display a special UI, notifying user after disconnection:

const { useCallCallingState } = useCallStateHooks();
const callingState = useCallCallingState();

if (callingState === CallingState.RECONNECTING_FAILED) {
  return <ConnectionError />; // display connection error UI
}
© Getstream.io, Inc. All Rights Reserved.