Skip to main content

Why does it take a long time for a device to appear offline?

ESP RainMaker devices connect to the cloud over MQTT, which uses keep-alive messages to detect if the connection is active. As per MQTT Specs v3.1.1, if the Keep Alive value is non-zero and the Server does not receive a Control Packet from the Client within one and a half times the Keep Alive time period, it must disconnect the Network Connection to the Client as if the network had failed.

In ESP RainMaker, the keep-alive time is 120 seconds. Therefore, it can take up to 180 seconds (3 minutes) for the server to detect that a device has disconnected. A smaller keep-alive value would enable faster detection, but is undesirable as it can result in unnecessary network traffic and cause frequent disconnect events when network strength is poor.

note

Changing the keep-alive value is not recommended, but you can do so via CONFIG_ESP_RMAKER_MQTT_KEEP_ALIVE_INTERVAL in menuconfig if needed.