#NGO automatic region select problem

1 messages · Page 1 of 1 (latest)

toxic heart
#

I'm using Netcode for GameObjects 2.3 with multiplayer service (Distributed Authority)

I'm creating a lobby here that seems to select the optimal region itself.

My problem:
Sometimes, I get a lobby with a good ping (< 100ms), but sometimes the client has over 400ms ping all the time, probably because it selected the wrong region.

How can I get the selected region, and how can I provide the option to select another region after creating the lobby so players could optionally change region if it's bad?

The bad behaviour was observed in europe (idk about other places).

#

Here's the code for creating the lobby:

using unity netcode for gameobjects, how can i print the region it selected?

public static async Task CreateSessionAsync(string sessionName, int maxPlayers, Database.GameType gameType) {
        _ctsCreateLobby?.Dispose();
        _ctsCreateLobby = new CancellationTokenSource();

        try {
            SessionOptions options = new SessionOptions {
                IsPrivate = true,
                MaxPlayers = maxPlayers,
                Name = sessionName,
                SessionProperties = new Dictionary<string, SessionProperty> {
                {
                    // Setting properties
            },
            }.WithDistributedAuthorityNetwork();

            IHostSession hostSession = (IHostSession)await RunWithCancellation(
                ct => MultiplayerService.Instance.CreateSessionAsync(options),
                _ctsCreateLobby.Token
            );

            ISession session = hostSession;
            Database.S.joinedSession = session;

            Debug.Log($"Created Session! {session.Name} {session.MaxPlayers} {session.Id} {session.Code}");

            UpdatePlayerProperties(GetDefaultPlayerProperties());
            _lastSessionUpdateTimestamp = Time.unscaledTime;
            _lastPlayerUpdateTimestamp = Time.unscaledTime;
        }
        catch (SessionException e) {
            Debug.Log(e);
            throw;
        }
    }
true finch
toxic heart
#

So i would call GetSortedQosResultsAsync(string, then specify the best region manually based on the result?

#

Shouldn't that happen automatically? Why does it sometimes select the wrong region? And can i somehow print the selected region for debugging?

true finch
#

You shouldn't have to. It will automatically get the best region when the session is created

true finch
toxic heart
true finch
#

It chooses the one with the lowest ping. But that is only for the session owner. Other clients that connect will be connecting to that region. If you players are in different regions then one of them will have a bad ping

toxic heart
#

That's what's so strange... I used the multiplayer testing tool (ParrelSync?), and i had the 500 ping there sometimes and sometimes everything was fine (both clients on the same PC)

#

Also, i had the same issue in one match with my friend that lives in the same town as me

#

Although in most cases everything is fine

#

Can't understand

true finch
#

Have you tested it out just using Relay instead of distributed authority?

toxic heart
#

No, my game depends on DA, can't swap to relay

true finch
#

You can open a ticket on the Cloud Dashboard page the services team can look into what might be happening

toxic heart
#

Ok, where is that exactly?

true finch
toxic heart
#

Alright thanks

toxic heart
#

hey sorry to bother again:
I'm trying to get the sorted regions with GetSortedQosResultsAsync(string, IList<string>)
(https://docs.unity3d.com/Packages/com.unity.services.qos@1.3/api/Unity.Services.Qos.IQosService.html#Unity_Services_Qos_IQosService_GetSortedQosResultsAsync_System_String_System_Collections_Generic_IList_System_String__)

this returns me IQosResult.
i can get the best region with result.First().Region

issue is that the best region will look like this "4f415cb0-d6c0-11ec-a066-728ac7d1b0a4", but the method WithDistributedAuthorityNetwork() expects something like this "us-central1"

guess i somehow need to convert the id to the region name, but i can't find a way to do so...

true finch
toxic heart
#

it is indeed