Relay Server Expires (NGO)

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?

According to the docs, the connection to the Relay is automatically kept alive in NGO.
https://docs.unity.com/ugs/en-us/manual/relay/manual/keep-connection-alive

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.

Thanks,
Fraccas

1 Like

For additional information, it appears the Relay tends to go offline during periods in which our US testers are not joining the server.

I’m looking to determine how the dedicated server can detect that the Relay server is no longer alive.

https://docs.unity.com/ugs/manual/relay/manual/keep-connection-alive

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.

9699428--1384724--upload_2024-3-13_14-53-15.png

but it also mentions if you have say a coroutine sending data it should. so your host can join as a client and send keepalives

This appears to have resolved the issue.
https://docs.unity.com/ugs/manual/relay/manual/relay-and-utp

// 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