Connection between my game and the server randomly resets

Hi. I’m running nakama 3.18.0+095c7a66 on google kubernetes engine. I have a game built with flutter connecting to this instance. I used an open source client package(https://pub.dev/packages/nakama) to connect to the server. It works well most of the time but sometimes it seems the connection just randomly resets. When i check the server logs, this is what i get:

{
insertId: "2pmifh578istgvk3"
jsonPayload: {
caller: "server/session_ws.go:204"
error: "read tcp 10.46.0.84:7350->10.204.15.231:55428: read: connection reset by peer"
level: "debug"
msg: "Error reading message from client"
sid: "cfd80d63-adff-11ee-aaab-006100a0eb06"
ts: "2024-01-08T08:32:55.928Z"
uid: "ab60f590-65e5-437b-98db-2f517c64f344"
}
labels: {6}
logName: "projects/nouns-d1b26/logs/stdout"
receiveTimestamp: "2024-01-08T08:33:00.837332261Z"
resource: {2}
severity: "DEBUG"
timestamp: "2024-01-08T08:32:55.928445548Z"
}

The error, specifically, is read tcp 10.46.0.84:7350->10.204.15.231:55428: read: connection reset by peer
Error reading message from client

I don’t know how to resolve the issue. Or is it possible it’s the client package with an issue?
I have a stable and reliable connection so this is not the issue. Also the error has been reported by several players of my game

This depends on how you’ve configured your server deployment, and also where you are connecting to and where the servers are hosted. It’s possible that your connection latency is causing the server/client to think that they are disconnected. You may want to tweak your ping/pong and socket configuration in the server configuration.

@mofirouz
Alright, so I’m assuming the properties to tweak in the server configuration are
socket.ping_period_ms whose default is 15 seconds and socket.pong_wait_ms whose default is 25 seconds?

Here is what I have in my config so far

logger:
  level: "debug"
database:
  address:
    - "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
session:
  single_socket: true
  single_match: true
  refresh_token_expiry_sec: 3153600000 #100 years
  token_expiry_sec: 3153600000 #100 years
social:
  apple:
    bundle_id: "xxxxxxxxxxxxxxxxxxxxxxxx"

Would increasing the ping_period_ms and pong_wait_ms to about 1 full minute be too much?

I have the same issue
my config:
ping_period_ms: 4000
pong_wait_ms: 8000