Hello, I have a dedicated server running at all times using NGO, lobbies, and a relay server to allow WebGL. It seems like after some time the relay server expires and players can no longer join the server.
What is the expiration period for a Relay and how do I keep it alive for extended periods?
If this can’t be done, is there a way to detect when the Relay server expires so I can restart it?
For games with a lower message frequency, it’s important to keep the connection alive with a method that you regularly call, such as in the Update() loop. If you’re using Relay with NGO, the network manager (NetworkManager) keeps the connection alive automatically. However, it will only do so after you’ve successfully called StartClient or StartHost.
I linked these docs in my post. Though the docs state that NGO handles keeping the connection alive automatically once StartHost() is called, this doesn’t appear to be the case.
// Create NetworkSettings using the Relay server data to keep relay alive
var settings = new NetworkSettings();
settings.WithRelayParameters(ref relayServerData);
// Create the Host's NetworkDriver from the NetworkSettings.
var hostDriver = NetworkDriver.Create(settings);
// Bind to the Relay server.
if (hostDriver.Bind(NetworkEndpoint.AnyIpv4) != 0)
{
Debug.LogError("Host client failed to bind");
}
else
{
if (hostDriver.Listen() != 0)
{
Debug.LogError("Host client failed to listen");
}
else
{
Debug.Log("Host client bound to Relay server");
}
}
// End Create NetworkSettings using the Relay server data to keep relay alive