# Automatic Reconnection

Auto-reconnect refers to a feature that automatically attempts to re-establish a lost connection during a video conference session, in case of connection issues like poor network or exchanging between Wi-Fi and cellular network. Auto-reconnect in video conferencing swiftly restores connections, eliminating the need for manual reconnection.

Auto-reconnect functionality serves several use cases across different domains. Here are some common use cases for auto-reconnect:

Video Conferencing:

* Scenario: A user experiences a brief network disruption during a video conference.
* Use Case: Auto-reconnect ensures seamless participation by automatically attempting to restore the connection, minimizing disruptions in virtual meetings.

Mobile Applications:

* Scenario: A mobile user moves between different network environments (Wi-Fi to cellular, for example).
* Use Case: Auto-reconnect adapts to changing network conditions, allowing users to stay connected during transitions and providing a smoother mobile experience.

Cloud Services:

* Scenario: Cloud-based applications face occasional server unavailability.
* Use Case: Auto-reconnect enables applications to automatically retry connections to cloud servers, improving the reliability of cloud-based services.

Auto-Reconnect isn't enabled by default in the SDK and by following the below steps clients can implement it in their application.

**Steps to Use the API:**

To use the API for reconnecting the call user needs to register Reconnect Event listener as follows.                &#x20;

**Register Listeners:**

1\)      **Register for reconnecting events.**

public class MyClass : Connector.IRegisterReconnectEventListener

&#x20;   {

&#x20;public void OnConferenceLost(Connector.ConnectorFailReason reason)

&#x20;       {/\*You can Change the Connection state to disconnected\*/}               &#x20;

&#x20;public void OnReconnected()

&#x20;       {/\* You can Change the Connection state to connected\*/}

public void OnReconnecting(uint attempt, uint attemptTimeout, Connector.ConnectorFailReason reason)

&#x20;       { /\* \*/}

&#x20;   }

There are three cases that can occur during reconnecting: conference lost, reconnected and reconnecting.

**OnConferenceLost** - This callback will be triggered when the reconnecting attempt started.

**Reconnected**: This callback will be triggered when the connection was established, and the user joined to the call/conference.

**Reconnecting**: This callback will be triggered when the reconnecting attempt started.

2\)      Call the \_connector.RegisterReconnectEventListener() method.

**To Enable AutoReconnect:**

\-          Enable the Auto Reconnect as follows:

VidyoConnectorSetAdvancedOptions(vc, “{“enableAutoReconnect“ : true}“);

**For example using windows SDK (C#)** you can use the API as: \_connector.SetAdvancedOptions("{\\"enableAutoReconnect\\" : true}");

\-       You can also set the number of attempts and backoff time to be taken before reconnecting/disconnecting as follows:

**To Set reconnect Attempts and reconnectBackoff time:**

VidyoConnectorSetAdvancedOptions(vc, “{“enableAutoReconnect“ : true, “maxReconnectAttempts“ : 4, “reconnectBackoff“ :  5}“);

·       **maxReconnectAttempts**: Number of attempts to tried before disconnecting the call.

·       **reconnectBackoff** : waiting period before next attempt and **this** will be doubled on every next attempt.

**In C#:** \_connector.SetAdvancedOptions("{\\"enableAutoReconnect\\" : true, \\"maxReconnectAttempts\\" : 4, \\"reconnectBackoff\\" :  5}");

**To Disable Reconnect:**

VidyoConnectorSetAdvancedOptions(vc, “{“enableAutoReconnect“ : false}“);

**In C#:** \_connector.SetAdvancedOptions("{\\"enableAutoReconnect\\" : false}");

Auto-reconnect feature in video conferencing plays a crucial role in maintaining a reliable and user-friendly communication environment. It helps reduce downtime, ensures seamless connectivity, and contributes to a positive user experience, ultimately supporting effective collaboration in both professional and personal settings.
