I’m new to Nakama and have been following the “Nakama in Unity” playlist. I managed to get the Nakama server running with Docker and I’m now stuck at the Matchmaking tutorial.
I pressed the “Find Match” button on both instances of the game but I do not get the printed message that happens at 8:22 of the eighth tutorial. I checked the server console and it did register 2 matchmaking tickets. Below is my script so far:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Nakama;
public class NakamaConnection : MonoBehaviour
{
string scheme = "http";
string host = "localhost";
int port = 7350;
string serverKey = "defaultkey";
IClient client;
ISession session;
ISocket socket;
string ticket;
async void Start()
{
client = new Client(scheme, host, port, serverKey, UnityWebRequestAdapter.Instance);
session = await client.AuthenticateDeviceAsync(SystemInfo.deviceUniqueIdentifier);
Debug.LogFormat("New user: {0}, {1}", session.Created, session);
socket = client.NewSocket(true);
socket.ReceivedMatchmakerMatched += OnReceivedMatchkamerMatched;
await socket.ConnectAsync(session, true);
Debug.Log(socket);
}
public async void FindMatch()
{
Debug.Log("Finding match");
var matchmakingTicket = await socket.AddMatchmakerAsync("*", 2, 2);
ticket = matchmakingTicket.Ticket;
}
async void OnReceivedMatchkamerMatched(IMatchmakerMatched MatchmakerMatched)
{
Debug.Log("Joining match....");
var match = await socket.JoinMatchAsync(MatchmakerMatched);
Debug.Log("Our sessions ID: " + match.Self.SessionId);
foreach(var user in match.Presences)
{
Debug.Log("Connected User Session ID: " + user.SessionId);
}
}
}
The only other thing I noticed that was different from the video was when it printed my session, the Created property was false instead of true like the video.
So I tried testing the matchmaking with the fish-game project and it works! I am also able to do the matchmaking on my own game now using the server that was created from the fish-game project. So there must be something off about my docker-compose.yml. This is mine:
Containers seem to use different configuration files from different file locations. Can you try to find out if there is some major difference between them?
Yes. Server will probably try to look for config.yml or something similar in mapped directory. You can see which config file is used on first log row after server start.
If so, both of the server logs has the same path. However, the folder where I have the docker-compose.yml file doesn’t have a nakama folder, it only has a modules folder. Could that be the cause of the problem?
@ProgramPlotam Can you please update to Nakama 3.10.0 and test again? If I recall correctly there was a matchmaker issue specific to the 3.9.0 release that was fixed in the very next release.
@zyro Hey thanks for the suggestion. I can finally connect using my own docker-compose. Everything looks to be working fine and I’ll be continuing the tutorial. Thank you very much!