Improbable Icon

Testing Matchmaking Server in Unity Editor

I’ve managed to get my matchmaking server working, using the PIT and LT workflow. It works great when testing in the Unity Editor and routes me to the first suitable deployment, but I only connect successfully when the deployment chosen by the matchmaker is the one I ran spatial cloud connect external for.

What’s my best bet for testing this in the editor? Is there a way to have connection open for all the available deployments?


Hi @basil, it sounds like the connection you may be attempting to make is a local connection (hence only the tunneled attempt working). Can you show me your connection logic?

One important part of the player-auth docs is the UseExternalIp = true network parameter.
UseExternalIP signals to the WorkerSDK to use the public IP address of the deployment services rather than the private ones. This is crucial for workers connecting from outside of the cloud network and could be the reason for these connectivity issues.

Hey, thanks for the quick response. Here’s my Connect method in my UnityClientConnector.cs script:

private async void Connect(string PIT, string LT)

        var connParams = CreateConnectionParameters(WorkerUtils.UnityClient);
        connParams.Network.UseExternalIp = true;
        connParams.Network.ConnectionType = NetworkConnectionType.RakNet;
        var builder = new SpatialOSConnectionHandlerBuilder()

        var initializer = new CommandLineConnectionFlowInitializer();
        if (!Application.isEditor) {
            switch (initializer.GetConnectionService())
                case ConnectionService.Receptionist:
                builder.SetConnectionFlow(new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient),
                case ConnectionService.Locator:
                    // Authenticate Locator Flow with PIT and LT
                    var locatorFlow = new LocatorFlow(initializer);
                    locatorFlow.PlayerIdentityToken = PIT;
                    locatorFlow.LoginToken = LT;
                throw new ArgumentOutOfRangeException();
            Debug.Log(("In Editor - set receptionist flow"));
            var connFlow = new ReceptionistFlow(CreateNewWorkerId(WorkerUtils.UnityClient));
            if (!string.IsNullOrEmpty(RuntimeIp))
                connFlow.ReceptionistHost = RuntimeIp;


        await Connect(builder, new ForwardingDispatcher()).ConfigureAwait(false);

Hey @basil, in your else-block (the in-editor flow), you should be connecting via the locator as shown in this doc.

What I think might be happening is that while in-editor, your script is attempting to use the local receptionist which is tunneled to the cloud deployment receptionist from the spatial cloud connect external command.

Hey, in the code from that page in the docs- how do I find LocatorServerAddress and LocatorServerPort?

In the meantime I tried replacing my code in the Else statement to

var locatorFlow = new LocatorFlow(initializer);
locatorFlow.PlayerIdentityToken = PIT;
locatorFlow.LoginToken = LT;

but it’s returning “Failed to create worker”

Hi @basil, the locator host is and you can use port 443 (see RuntimeConfigDetails).

Where are you seeing that error? Are you able to see any connection attempt being made to the cloud deployment? I’m not sure what’s present in that initializer, so it may be worth checking to see what’s being passed to the LocatorFlow in that.

My current code is:

// If In Editor
            var locatorParameters = new LocatorParameters
                PlayerIdentity = new PlayerIdentityCredentials
                    PlayerIdentityToken = PIT,
                    LoginToken = LT
            var locator = new Locator("", (ushort) 443, locatorParameters);
            using (var connectionFuture = locator.ConnectAsync(new ConnectionParameters
                WorkerType = "UnityClient",
                Network = {ConnectionType = NetworkConnectionType.Tcp, UseExternalIp = true}
                var connFuture = connectionFuture.Get();
                if (!connFuture.IsConnected) throw new Exception("No connection or connection not established");
                Console.WriteLine($"Assigned worker ID: {connFuture.GetWorkerId()}");

I have this error now:

InvalidCredentialException: ConnectAsync requires PlayerIdentity credentials to be used in the Locator

It’s strange because I surely set the PlayerIdentity in LocatorParameters. Any ideas?

Thanks again :slight_smile:

Hey @basil - would you be able to confirm for me the version of the GDK that you’re on?
There have been some breaking changes in the connector flow logic (in 0.2.7) so I want to make sure we’re on the same page.

Could you also double check that the LT and PIT are valid as previously you were connecting via the tunneled receptionist, so we might have some legitimately invalid credentials.