Skip to content
Stand with Ukraine flag

Edge randomly disconnects

If an Edge instance repeatedly disconnects and reconnects to the server within a few seconds without an obvious cause, the most likely explanation is unstable network connectivity — low bandwidth, intermittent packet loss, or a NAT/load balancer dropping idle connections. The gRPC keepalive parameters control how the connection is probed and how long both sides wait before declaring it dead.

Before tuning keepalive parameters, verify the network is actually the cause:

  • Check Edge logs for connection errors: cat /var/log/tb-edge/tb-edge.log | grep ERROR
  • Test round-trip latency to the server: ping server_hostname
  • Check for packet loss: mtr server_hostname

If the network is stable and disconnections persist, consider other causes such as resource exhaustion on the Edge device.

Keepalive is configured independently on both sides. Both must be adjusted together — mismatched values will cause the server to terminate connections that the client considers healthy.

Server parameters (/etc/thingsboard/conf/thingsboard.conf)

Section titled “Server parameters (/etc/thingsboard/conf/thingsboard.conf)”
ParameterDefaultDescription
EDGES_RPC_CLIENT_MAX_KEEP_ALIVE_TIME_SEC1 sMinimum allowed interval between client keepalive pings. If a client pings more frequently than this, the server can terminate the connection.
EDGES_RPC_KEEP_ALIVE_TIME_SEC10 sTime of inactivity after which the server sends a keepalive ping to the client.
EDGES_RPC_KEEP_ALIVE_TIMEOUT_SEC5 sMaximum time the server waits for a response to its keepalive ping before closing the connection.

Edge parameters (/etc/tb-edge/conf/tb-edge.conf)

Section titled “Edge parameters (/etc/tb-edge/conf/tb-edge.conf)”
ParameterDefaultDescription
CLOUD_RPC_KEEP_ALIVE_TIME_SEC10 sTime of inactivity after which the Edge sends a keepalive ping to the server. Keeps the connection alive through NATs and load balancers that drop idle flows.
CLOUD_RPC_KEEP_ALIVE_TIMEOUT_SEC5 sMaximum time the Edge waits for a response to its keepalive ping before considering the connection dead and attempting to reconnect.

On the ThingsBoard server, edit /etc/thingsboard/conf/thingsboard.conf and add:

Terminal window
export EDGES_RPC_CLIENT_MAX_KEEP_ALIVE_TIME_SEC=1
export EDGES_RPC_KEEP_ALIVE_TIME_SEC=30
export EDGES_RPC_KEEP_ALIVE_TIMEOUT_SEC=25

On the Edge device, edit /etc/tb-edge/conf/tb-edge.conf and add:

Terminal window
export CLOUD_RPC_KEEP_ALIVE_TIME_SEC=30
export CLOUD_RPC_KEEP_ALIVE_TIMEOUT_SEC=25

Restart both services to apply the changes:

Terminal window
sudo systemctl restart thingsboard
sudo systemctl restart tb-edge