Copyright ©

Mongoose OS Forum


MQTT disconnection event

I am trying to use the MQTT & WiFi disconnection event to flag that the connection to server is lost.

The WiFi disconnection event is triggered immediately after the router is switched off. But the MQTT disconnection event is getting triggered more than 2 minutes after the internet is disconnected from the router to which the ESP is connected. I tried changing the keep alive from 30s to 10s but is does not matter.

Code used
if ( ev !== 0 ) {
print("MQTT Event:",ev);
if( ev === MQTT.EV_CONNACK ) {
UART.write(UART_DEBUG,"MQTT Connection Acknowledge:", JSON.stringify(ev));
if( ev === MQTT.EV_CLOSE ) {
UART.write(UART_DEBUG,"MQTT DisConnection:", JSON.stringify(ev));

Is it possible to reduce the time before the MQTT.EV_CLOSE event gets triggered?


Sign In or Register to comment.