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.
Diagnose first
Section titled “Diagnose first”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 parameters
Section titled “Keepalive parameters”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)”| Parameter | Default | Description |
|---|---|---|
EDGES_RPC_CLIENT_MAX_KEEP_ALIVE_TIME_SEC | 1 s | Minimum 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_SEC | 10 s | Time of inactivity after which the server sends a keepalive ping to the client. |
EDGES_RPC_KEEP_ALIVE_TIMEOUT_SEC | 5 s | Maximum 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)”| Parameter | Default | Description |
|---|---|---|
CLOUD_RPC_KEEP_ALIVE_TIME_SEC | 10 s | Time 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_SEC | 5 s | Maximum time the Edge waits for a response to its keepalive ping before considering the connection dead and attempting to reconnect. |
Apply the changes
Section titled “Apply the changes”On the ThingsBoard server, edit /etc/thingsboard/conf/thingsboard.conf and add:
export EDGES_RPC_CLIENT_MAX_KEEP_ALIVE_TIME_SEC=1export EDGES_RPC_KEEP_ALIVE_TIME_SEC=30export EDGES_RPC_KEEP_ALIVE_TIMEOUT_SEC=25On the Edge device, edit /etc/tb-edge/conf/tb-edge.conf and add:
export CLOUD_RPC_KEEP_ALIVE_TIME_SEC=30export CLOUD_RPC_KEEP_ALIVE_TIMEOUT_SEC=25Restart both services to apply the changes:
sudo systemctl restart thingsboardsudo systemctl restart tb-edgeOn the ThingsBoard server, stop the container, edit docker-compose.yml, and add to the environment block:
- EDGES_RPC_CLIENT_MAX_KEEP_ALIVE_TIME_SEC=1 - EDGES_RPC_KEEP_ALIVE_TIME_SEC=30 - EDGES_RPC_KEEP_ALIVE_TIMEOUT_SEC=25On the Edge device, stop the container, edit docker-compose.yml, and add to the environment block:
- CLOUD_RPC_KEEP_ALIVE_TIME_SEC=30 - CLOUD_RPC_KEEP_ALIVE_TIMEOUT_SEC=25Start both containers after making the changes.