Hi everyone,
I’m fairly new to Nakama and I’m trying to run the Github source code for tictactoe made with Nakama and Phaser. When I start a new game, I get the error that says that I have an uncaught(in promise) for findmatch(), which I looked into for a while to understand, but I still couldn’t figure out the error. What am I supposed to do right now? I’m running the server with docker at the moment.
Hi @Ongun1905,
Please can you confirm that you’re running the nakama-project-template server? This server has some custom server runtime code that will provide the findMatch
function you’re missing.
We’ve recently updated the Tic-Tac-Toe tutorial to make this step a bit clearer.
If you’re still experiencing issues please do let me know.
Hi @tom ,
Thank you for the response. I fixed it right now, I am running the Nakama project template server at the moment.
One issue I’m having right now is that when I try to find a match I get an error in the console which says that “WebSocket is closed or already in the closing state”. I am running two localhosts in the incognito tab. However, I fixed this issue by removing an if statement and only keeping the body of that if statement in nakama.js which checks if the deviceId already exists. I got it to work on some point where the board updates on both localhosts but updating turns doesn’t work.
Hi @Ongun1905, glad you got it working.
Yes indeed, the issue you mentioned is due to the same device ID being used to connect twice. Our updated docs mention this. While testing locally I would advise setting deviceId
to uuidv4()
so that a new device ID is generated for each client.
I also fixed the issue of player turns by setting userId in setPlayerTurn() to nakama.session.user_id
Thanks so much Tom!