TaskCanceledException in Unity while matchmaking

I get this error when i try to matchmake:

I’m runniing Nakama locally on my machine and there aren’t any modules loaded. This is my code in Unity

 private async void Awake()
        var authtoken = PlayerPrefs.GetString(PrefKeyName);
        if (!string.IsNullOrEmpty(authtoken))
            var session = Session.Restore(authtoken);
            if (!session.IsExpired)
                _session = session;
        var deviceid = SystemInfo.deviceUniqueIdentifier;
        _session = await _client.AuthenticateDeviceAsync(deviceid);
        PlayerPrefs.SetString(PrefKeyName, _session.AuthToken);
        _socket = _client.NewSocket();
        _socket.ReceivedMatchmakerMatched += async matched =>
            Debug.LogFormat("Received: {0}", matched);
            await _socket.JoinMatchAsync(matched);
        var matchmakerTicket = await _socket.AddMatchmakerAsync();

I get an error on the last line where it says matchmakerTicket. Any help would be appreciated.

You seem to be creating the socket, but you never connect it. You should do that as shown in the .NET/Unity client guide docs.

thank you so much. Its my first time with Nakama so i appreciate the help.

1 Like