Left here for archival purposes.

User avatar
By lepass7
#37163 Hello,
I think there is a bug on mqtt clinet keep alive timer.
Code: Select allm = mqtt.Client("ESP"..node.chipid(), 120, "user", "password")
m:lwt(PUB_TOPIC, "offline", 0, 0)
m:on("connect", function(conn) print("mqtt_connected") end)
m:on("offline", function(conn) print("offline") end)
m:on("message", function(conn, topic, data) receive_data(data, topic) end)


As you can see on the first line I am creating a client with keep alive time 120 secs, so if the client lost internet connection for more than 120 seconds it should fire up m:on("offline"... event. It seems that it needs more time (about 14-15 minutes to fire up the offline event).

Is this a bug? Or is something wrong on my code? I tried to change 120 seconds to 0,1, 10, 60 seconds but always the response is the same, the offline event raised at 13-16 minutes.
Below you can see build information:
NodeMCU custom build by frightanic.com
branch: master
commit: 93421f2702fb02ce169f82f96be7f2a8865511e1
SSL: true
modules: node,file,gpio,wifi,net,pwm,i2c,spi,tmr,adc,uart,ow,bit,mqtt,coap,u8g,ws2812,cjson,crypto,rc,dht,ws2801,rtcmem,rtctime,rtcfifo,sntp,bmp085,tsl2561,ucg,enduser_setup,hx711
build built on: 2015-12-19 06:31
powered by Lua 5.1.4 on SDK 1.4.0