Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

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
MQTT.setEventHandler(function(conn,ev,evdata){
if ( ev !== 0 ) {
print("MQTT Event:",ev);
}
// MG_EV_MQTT_CONNACK
if( ev === MQTT.EV_CONNACK ) {
UART.write(UART_DEBUG,"MQTT Connection Acknowledge:", JSON.stringify(ev));
}
// MG_EV_MQTT_DISCONNECT
if( ev === MQTT.EV_CLOSE ) {
UART.write(UART_DEBUG,"MQTT DisConnection:", JSON.stringify(ev));
}
},null);

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

Comments

Sign In or Register to comment.