Nakama server throwing excessive 401

Hello, I’m testing Nakama to see if it fits our use case (creating a TCG simulator).
I’m deploying a nakama server on Fly.io, and I am observing a increased number of 401 responses from Nakama. Looking at the docs it mentions that it could be sessions getting invalidated in the middle of a game session, I changed logic a bit and I still see a lot of 401 responses.

I’d like to ask some tips about how I could debug this, I’m not able to see anything in the logs (other than socket closed).

Could you give me some hints on how I could debug this?

Hello @eduardomoroni,

What version of Nakama are you using?

Make sure you’ve updated the config values to sensible values.

I believe most of the official SDKs handle token refresh automatically, but otherwise you must implement this logic yourself.

Best.

I’m using v3.26.0, I was able to narrow down the problem to traffic coming from somewhere else (not from the game), probably bots.

I was able to temporarily fix it by changing the server’s IP, but it will eventually happen again. So I wonder what could I do to manage this scenario. is there a way of knowing (perhaps through prometheus) which endpoints are returning 401?

The alternative I see is moving the server to Cloudflare and add firewall rules based on request headers