Connection retry
In a situation where our app starts with poor or no internet connection, we see that Normcore will time out, and our only recourse currently is to restart our app. Is there a way to set up a reconnection system so the app keeps trying?
4 Replies
Hi @petemoss. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Normcore does not provide a built-in automatic reconnection system for client-side disconnections due to poor or no internet connection, according to the available documentation. However, you can implement your own reconnection logic in Unity by listening for the
didDisconnectFromRoom
event on the Realtime
component and then attempting to reconnect when a disconnection occurs.
Here’s an example pattern, adapted from the server plugin documentation, which you can use on the client side as well:
This approach will keep trying to reconnect whenever a disconnection occurs, which should help in scenarios where the app starts with a poor or no internet connection. You can adjust the delay and add additional logic (such as a maximum number of retries or exponential backoff) as needed for your application.
The reconnection pattern is explicitly shown for server plugins, but the same event-driven approach applies to client code as well, since the didDisconnectFromRoom
event is available on the Realtime
component in Unity Normcore-private Server Plugins.
If you need more advanced connection management, you may need to implement additional logic yourself, as the knowledge sources do not mention a built-in client-side reconnection system.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@454336284178251778> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
awesome, thanks, i will give this a try
we’ve got an Autoreconnect component in the works too. I expect it to ship in the next few weeks