Hi,
I was trying to setup the username change feature in my game in Unity with Typescript and Postgres as language and db for Nakama. When I tried executing the code, the following error message appeared:
ApiResponseException(StatusCode=400, Message='Refresh token is required.', GrpcStatusCode=3)
That’s when I realized that my Session didn’t have any refresh token. A quick printout confirmed it:
Session(AuthToken='ey[...]A', Created=False, CreateTime=41, ExpireTime=1712723134, RefreshToken=, RefreshExpireTime=0, Variables={}, Username='Tatataaaa', UserId='ce54ce79-3abb-4770-8b27-ac51c827dfdf')
What is even weirder is the username getting stuck at a username that I was able to setup once but couldn’t do it again. Even when I restart my Docker Nakama, the data just doesn’t want to go away.
I tried to change my docker-compose file with the following:
entrypoint:
- "/bin/sh"
- "-ecx"
- >
/nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama &&
exec /nakama/nakama --name nakama1 --config /nakama/data/local.yml --database.address postgres:localdb@postgres:5432/nakama --logger.level DEBUG --session.token_expiry_sec 30 --session.refresh_token_expiry_sec 30
and the local.yml file like this:
name: nakama-node-1
data_dir: "./data"
logger:
stdout: true
level: "warn"
file: "/nakama/data/logfile.log"
runtime:
js_entrypoint: "build/index.js"
console:
port: 7351
username: "root"
password: "password"
session:
token_expiry_sec: 30
refresh_token_expiry_sec: 30
When I run docker-compose up --build, I get the following inputs during launch:
postgres | 2024-04-03 05:48:34.493 UTC [1] LOG: database system is ready to accept connections
nakama | + /nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama
nakama | {"level":"info","ts":"2024-04-03T05:48:37.834Z","caller":"migrate/migrate.go:155","msg":"Database connection","dsn":"postgres://postgres:xxxxx@postgres:5432/nakama?sslmode=prefer"}
nakama | {"level":"info","ts":"2024-04-03T05:48:37.840Z","caller":"migrate/migrate.go:203","msg":"Database information","version":"PostgreSQL 12.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.2.0) 9.2.0, 64-bit"}
nakama | {"level":"info","ts":"2024-04-03T05:48:37.842Z","caller":"migrate/migrate.go:226","msg":"Successfully applied migration","count":0}
nakama | + exec /nakama/nakama --name nakama1 --config /nakama/data/local.yml --database.address postgres:localdb@postgres:5432/nakama --logger.level DEBUG --session.token_expiry_sec 30 --session.refresh_token_expiry_sec 30
nakama | {"level":"info","ts":"2024-04-03T05:48:37.854Z","caller":"server/config.go:90","msg":"Successfully loaded config file","path":"/nakama/data/local.yml"}
nakama | {"level":"warn","ts":"2024-04-03T05:48:37.854Z","caller":"server/config.go:325","msg":"WARNING: insecure default parameter value, change this for production!","param":"console.password"}
nakama | {"level":"warn","ts":"2024-04-03T05:48:37.854Z","caller":"server/config.go:329","msg":"WARNING: insecure default parameter value, change this for production!","param":"console.signing_key"}
nakama | {"level":"warn","ts":"2024-04-03T05:48:37.854Z","caller":"server/config.go:333","msg":"WARNING: insecure default parameter value, change this for production!","param":"socket.server_key"}
nakama | {"level":"warn","ts":"2024-04-03T05:48:37.854Z","caller":"server/config.go:337","msg":"WARNING: insecure default parameter value, change this for production!","param":"session.encryption_key"}
nakama | {"level":"warn","ts":"2024-04-03T05:48:37.854Z","caller":"server/config.go:341","msg":"WARNING: insecure default parameter value, change this for production!","param":"session.refresh_encryption_key"}
nakama | {"level":"warn","ts":"2024-04-03T05:48:37.854Z","caller":"server/config.go:345","msg":"WARNING: insecure default parameter value, change this for production!","param":"runtime.http_key"}
nakama | {"level":"info","ts":"2024-04-03T05:48:37.854Z","caller":"main.go:113","msg":"Nakama starting"}
I feel like I am missing an important concept and way of doing with Nakama. Would be really appreciated if someone could go a bit in detail while explaining what is happening here.
Thank you a lot!