# TaskCanceledException in Unity while matchmaking

**URL:** <https://forum.heroiclabs.com/t/taskcanceledexception-in-unity-while-matchmaking/485>\
**Category:** Local Setup\
**Tags:** getting-started\
**Created:** [January 23, 2020, 12:29pm UTC](https://forum.heroiclabs.com/t/taskcanceledexception-in-unity-while-matchmaking/485 "2020-01-23T12:29:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shibli\_mansuri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/shibli_mansuri/32/160_2.png) [@shibli\_mansuri](https://forum.heroiclabs.com/u/shibli_mansuri)\
**Post date:** [January 23, 2020, 12:29pm UTC](https://forum.heroiclabs.com/t/taskcanceledexception-in-unity-while-matchmaking/485/1 "2020-01-23T12:29:09Z")

</div>

I get this error when i try to matchmake:

 ![Screenshot 2020-01-23 at 17.23.26](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/1X/9168aa9d31e1a9214213297ad0e97629e0bbdb66.png)

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

```auto
 private async void Awake()
    {
        var authtoken = PlayerPrefs.GetString(PrefKeyName);
        if (!string.IsNullOrEmpty(authtoken))
        {
            var session = Session.Restore(authtoken);
            if (!session.IsExpired)
            {
                _session = session;
                Debug.Log(_session);
                return;
            }
        }
        var deviceid = SystemInfo.deviceUniqueIdentifier;
        _session = await _client.AuthenticateDeviceAsync(deviceid);
        PlayerPrefs.SetString(PrefKeyName, _session.AuthToken);
        Debug.Log(_session);
        PlayerPrefs.Save();
        
        _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.

---

<div class="post-metadata">

**Author:** ![zyro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/zyro/32/14_2.png) [@zyro](https://forum.heroiclabs.com/u/zyro)\
**Post date:** [January 23, 2020, 12:47pm UTC](https://forum.heroiclabs.com/t/taskcanceledexception-in-unity-while-matchmaking/485/2 "2020-01-23T12:47:26Z")

</div>

> [@shibli\_mansuri](#):
>
> \_socket = \_client.NewSocket();

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](https://heroiclabs.com/docs/unity-client-guide/#socket-messages).

---

<div class="post-metadata">

**Author:** ![shibli\_mansuri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/shibli_mansuri/32/160_2.png) [@shibli\_mansuri](https://forum.heroiclabs.com/u/shibli_mansuri)\
**Post date:** [January 23, 2020, 5:13pm UTC](https://forum.heroiclabs.com/t/taskcanceledexception-in-unity-while-matchmaking/485/3 "2020-01-23T17:13:17Z")

</div>

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