The server encountered a temporary error and could not complete your request. (502)

ApiResponseException(StatusCode=-1, Message=’

502 Server Error

Error: Server Error

The server encountered a temporary error and could not complete your request.

Please try again in 30 seconds.

', GrpcStatusCode=-1)

Hi everyone,

So we keep seeing this log error on our server, it happens in random hours.
I’ve read about it and I saw that it’s related to load-balancing. The weird part is that we have only one instance of our server in Nakama.

Did anyone encounter this kind of error? Any suggestions on how to solve it or any walkaround?

Thank you in advance,

@avivInnplayLabs Do you have custom logic you run within the game server?

It’s quite possible that your custom logic has an error which causes the server to crash and be restarted. With only one instance running this would leave the load balancer without a backend to reach while the instance is restarted and you’d serve 502s to the game clients.

I recommend you trace your code to look for errors which might not be caught or handled correctly. A quick place to start is to use the Go linters available which will indicate where database resources handles leak or other errors within your code.

Hope this helps.

Hi thank you for your reply,

We are looking at our logs, and we see that it happens only to one user when it happens, and I would expect that it would happen to several users if the server crash.
We also do not see this issue when we run it on our test server on AWS.

Any future notes?

@avivInnplayLabs Interesting. If it only happens to one user can you compare their data stored to the data stored for another player that doesn’t have this issue. You can use the GDPR export option in the devconsole and then use a difftool to see what could be the root cause of the errors for that player. :thinking:

Let me clarify, It happens to one user at a time, not a single user from our user base. Sorry if I miss lead you.

@avivInnplayLabs Can you share the code which produces these errors? I suspect what happens is that you have a loop somewhere in that code which does not terminate correctly in some cases. This locks up the goroutine for the request and eventually fails at the load balancer.