-->
Page 1 of 3

MQTT client disconnect

PostPosted: Sun Jun 07, 2015 10:23 am
by El42
Hello,
I'm new in ESP8266 world, and probably I'm doing something wrong but I've some troubles about NodeMCU development board and MQTT.
I'm using ESP8266 with a temperature sensor DS18B20 to publish values with MQTT protocol each 5 minutes.
The NodeMCU MQTT client randomly disconnects from mosquitto broker (version 1.4) running on RaspberryPi, after some minutes or several hours. I've already changed USB power adapter and USB cable with no solution.
Any suggestion?

Thank you.

Re: MQTT client disconnect

PostPosted: Wed Jun 10, 2015 4:38 pm
by LastSamurai
I had a similar problem once (although I wasn't using NodeMCU) with mqtt. Does you ESP restarts/stop doing anything or does it just loose the connection?
For me the error was that I had some strings which I didn't clean up after using so after a certain amount of time the ESP would run out of memory and stop doing anything (sometimes even restarting). It was just standard C code with the SDK though...

Re: MQTT client disconnect

PostPosted: Wed Jun 10, 2015 5:21 pm
by El42
**** UPDATE ****
I've had also some network issues, now I've resolved them but there are always some disconnections.
I've done some checks in MQTT broker log and with a new test:
1) ESP8266 transmits a PUBLISH every 5 minutes (300 seconds)
2) MQTT client uses a keepalive period set to 120 seconds and sends a PINGREQ to MQTT broker every 121 seconds (see log extract below)
I see that disconnections aren't random but systematic:
1) when the PUBLISH and PINGREQ are synchronous, MQTT client send only the PINGREQ message and no PUBLISH (see *** in log extract)
2) after 5 minutes from this "specific" event in MQTT broker log I see a new reconnection from ESP8266
Code: Select all09/06/2015 09.27.04    Received PUBLISH from myESP
09/06/2015 09.29.00    Received PINGREQ from myESP
09/06/2015 09.29.00    Sending PINGRESP to myESP
09/06/2015 09.31.01    Received PINGREQ from myESP
09/06/2015 09.31.01    Sending PINGRESP to myESP
09/06/2015 09.32.04    Received PUBLISH from myESP
09/06/2015 09.33.02    Received PINGREQ from myESP
09/06/2015 09.33.02    Sending PINGRESP to myESP
09/06/2015 09.35.03    Received PINGREQ from myESP
09/06/2015 09.35.03    Sending PINGRESP to myESP
09/06/2015 09.37.04    Received PINGREQ from myESP ***
09/06/2015 09.37.04    Sending PINGRESP to myESP
09/06/2015 09.39.05    Received PINGREQ from myESP
09/06/2015 09.39.05    Sending PINGRESP to myESP
09/06/2015 09.41.06    Received PINGREQ from myESP
09/06/2015 09.41.06    Sending PINGRESP to myESP
09/06/2015 09.42.21    Client myESP already connected, closing old connection.
09/06/2015 09.42.21    Client myESP disconnected.
09/06/2015 09.42.21    New client connected from 192.168.0.19 as myESP (c1, k120).


Do you think is a bottleneck ?

Re: MQTT client disconnect

PostPosted: Thu Jun 11, 2015 12:38 am
by cal
Moin,

I would observe heap usage and time since last reboot. Sending them via mqtt may be nice way.
If you have memory problems or spontaneous reboots you should see then.

Cal