Problem with device authentication

Hi all, I have a Unity application that makes use of device authentication for user login/signup (i.e. using the device id).
Unfortunately sometimes, after I delete an account (from the Nakama dashboard) and then recreate it (with the function “client.AuthenticateDeviceAsync(deviceId)” and with the same device id), I get the error: “Username is already in use”.
This error is crazy because with this type of authentication the username is generated automatically by Nakama.
After several attempts the situation is unblocked and I can generate the user normally, do you know what the problem could be and how to solve it?

On the server side I use Nakama version 2.12.0+650b506a (self hosted on ubuntu server), on the client side I use version: 2.5.1.

Hello @lowslow,

Are there any relevant server side logs when you attempt to delete the user?

I’d strongly suggest that as a first step you upgrade Nakama, the version you’re using is 4+ years old, if you still encounter this issue after upgrading please report back.

Thank you for your reply, I will check the logs. Do you mean to upgrade only server side or also client side? Are there usually problems when upgrading or is there good backward compatibility?

We strive to keep backwards compatibility on the client-facing APIs always, I do not think there are breaking changes but 4 years worth of upgrades is a lot.

Bringing the client up-to-speed is probably a good idea too, it’ll expose a lot of the APIs that have since been introduced, improvements, fixes, etc.

Your client version should work without issue with the updated Nakama but given the amount of releases in between it’s hard to to give an absolute guarantee.

Hope this helps.

thanks you so much! I will create a test server by duplicating the main one and try to upgrade nakama to see what happens

I have tried to update Nakama server to the latest version, unfortunately a problem occurs: I have a Lua module (server-side) which takes care of initialising the user’s data when registering, in particular when I try to set the default wallet, I get this error:

“error”:"lua/init_user.lua:21: failed to update user wallet: ERROR: at or near ")": syntax error: unimplemented: arrays of jsonb not allowed (SQLSTATE 0A000)\nstack traceback:\n\t[G]: in function ‘wallet_update’\n\tlua/init_user.lua:21

What can it be? As a dbms I use Cockroach version 20.1.3, I hope it’s not a problem related to the version of Cockroach because I tried to update it, and I had problems because the new version couldn’t take the data of the old version (I have a lot of game data).

Hello @lowslow, unfortunately that issue happens due a query optimization change that was introduced in Nakama but that’s not supported by some versions of Cockroachdb so you’ll need to upgrade it, I know that on at least v22.2 it’s resolved.

The cockroachdb documentation should provide instructions on which upgrade paths are possible from the version you’re on, but you’ll likely have to upgrade sequentially from/to very specific versions.

I was able to do the cockroach update without losing any data, now I will try the application with the new version of Nakama, thank you very much!

1 Like