openhab MQTT connection lost

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
dduley
Normal user
Posts: 93
Joined: 06 Feb 2016, 17:56

openhab MQTT connection lost

#1 Post by dduley » 18 Feb 2016, 06:58

Hi,

I am using R78 with openhab and Mosquitto. All seems to connect just fine but if you watch the log the ESP will send three temperature transmissions followed by "MQTT : Connection lost
MQTT : Connected to broker" . This increases the error count. when the error count reaches 30 the ESP reboots. R48 does not do this. R48 will connect and run for days without a single connection error! I think something broke after R48.
Here is a snippet of the ESP log:
connected with shangrila, channel 1
ip:192.168.0.53,mask:255.255.255.0,gw:192.168.0.1
WIFI : Connected!
MQTT : Connected to broker
Subscribed to: /Studiolights/#
INIT : Boot OK
INIT : Normal boot
WD : Uptime 0 ConnectFailures 0 FreeMem 26096
MQTT : Connection lost
MQTT : Connected to broker
Subscribed to: /Studiolights/#
DS : Temperature: 27.56 (28-ff-f5-66-a6-15-4-f0)
MQTT : Topic: /Studiolights/temp/Temperature F
MQTT : Payload: 81.61
DS : Temperature: 27.56 (28-ff-f5-66-a6-15-4-f0)
DS : Temperature: 27.56 (28-ff-f5-66-a6-15-4-f0)
WD : Uptime 1 ConnectFailures 2 FreeMem 25920
MQTT : Connection lost
MQTT : Connected to broker
Subscribed to: /Studiolights/#
DS : Temperature: 27.62 (28-ff-f5-66-a6-15-4-f0)
MQTT : Topic: /Studiolights/temp/Temperature F
MQTT : Payload: 81.72
DS : Temperature: 27.62 (28-ff-f5-66-a6-15-4-f0)
DS : Temperature: 27.62 (28-ff-f5-66-a6-15-4-f0)
WD : Uptime 1 ConnectFailures 4 FreeMem 25840
MQTT : Connection lost
MQTT : Connected to broker
Subscribed to: /Studiolights/#
DS : Temperature: 27.62 (28-ff-f5-66-a6-15-4-f0)
MQTT : Topic: /Studiolights/temp/Temperature F
MQTT : Payload: 81.72


Also it would be nice to get the Event task back. This was useful to turn on local lights etc with local switches but still allow full computer control.

Thanks

bennybubble
Normal user
Posts: 44
Joined: 31 Jan 2016, 21:05

Re: openhab MQTT connection lost

#2 Post by bennybubble » 18 Feb 2016, 11:04

I had the same problems when more then 1 ESP** was connecting to the broker.
It turned out that the device number (in the config screen) has to be unique and not zero ... This solved my problem !

-ben

dduley
Normal user
Posts: 93
Joined: 06 Feb 2016, 17:56

Re: openhab MQTT connection lost

#3 Post by dduley » 19 Feb 2016, 05:06

Ben,

You, my friend, are awesome!!! I can now go bandage my head from beating it against the keyboard for the last week! This field should be documented better (or at all). I gave all of my ESP units a unique number and all my problems went away.

Thanks again

Dave

bennybubble
Normal user
Posts: 44
Joined: 31 Jan 2016, 21:05

Re: openhab MQTT connection lost

#4 Post by bennybubble » 19 Feb 2016, 10:07

Hi,

EaspEasy is a very nice product, people must have spend hours and hours to get it working (which is very much appreciated) but it lacks information like this.
Or at least it is difficult to find but this is why this forum is here !

-ben

Gorgo
Normal user
Posts: 20
Joined: 14 Feb 2016, 11:40

Re: openhab MQTT connection lost

#5 Post by Gorgo » 06 Mar 2016, 19:05

dduley wrote: Also it would be nice to get the Event task back. This was useful to turn on local lights etc with local switches but still allow full computer control.
That is exactly what I was looking for. Could you help me where could I find more about it?

Thanks in advance.

dduley
Normal user
Posts: 93
Joined: 06 Feb 2016, 17:56

Re: openhab MQTT connection lost

#6 Post by dduley » 07 Mar 2016, 06:15

Try going to the github site and look under "plugin playground". The event plugin is there

Gorgo
Normal user
Posts: 20
Joined: 14 Feb 2016, 11:40

Re: openhab MQTT connection lost

#7 Post by Gorgo » 10 Mar 2016, 20:23

Thank you.

foad62
New user
Posts: 6
Joined: 19 Apr 2017, 13:11

Re: openhab MQTT connection lost

#8 Post by foad62 » 25 Sep 2017, 16:19

Thank you!

DeNB3rt
Normal user
Posts: 120
Joined: 15 Dec 2015, 14:07

Re: openhab MQTT connection lost

#9 Post by DeNB3rt » 08 Oct 2017, 11:08

bennybubble wrote: 18 Feb 2016, 11:04 I had the same problems when more then 1 ESP** was connecting to the broker.
It turned out that the device number (in the config screen) has to be unique and not zero ... This solved my problem !

-ben
crap! was testing with one unit with mqtt, that was working perfectly. Later in a 'quick', I added a second one, since then it was working but sometimes not.
Because they were default unit no:0...
I know that the unit no was important, but thought it was something else.
Was checking rbpi config, domoticz,...

Code: Select all

66756 : MQTT : Connection lost
67802 : MQTT : Connected to broker
67807 : Subscribed to: domoticz/out
you saved my life :D
Located in Belgium, Bruges. Working on a full DIY domoticz setup with ESPEasy.

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: openhab MQTT connection lost

#10 Post by zupy666 » 19 Aug 2020, 15:22

Hello everyone, I still have this problem.
I have 26 devices in the network and each of them has a unique “Unit Number” value. I use different firmware versions (R147, R148, v2.0.0-dev12, mega-20181122, mega-20181231, mega-20190511).
Version of OH 2.5.5.
I was temporarily forced to add a rule to an individual node to reboot in case of loss of mqtt connection. But I really don’t want to keep that long-term.

Anyone any idea?

thanks for the help

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: openhab MQTT connection lost

#11 Post by TD-er » 19 Aug 2020, 15:43

Have you also tried a more recent build?
A lot improvements have been made since 201905...

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: openhab MQTT connection lost

#12 Post by zupy666 » 19 Aug 2020, 16:37

I haven't succeeded yet :( .... At the same time I have three sonoff pow r2 for which only the mega-20181231 version is available. Am I wrong?
For other nodes I will try a newer version of FW.

Thanks for the tip :)

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: openhab MQTT connection lost

#13 Post by TD-er » 19 Aug 2020, 21:59

See here: https://github.com/letscontrolit/ESPEasy/releases
I just checked one of the latest builds and in there is the ESP_Easy_mega_20200812_hard_SONOFF_POW_4M1M.bin
So you should be possible to OTA to one of the newer builds for Sonoff POW units.

N.B. when upgrading from an older build, only use the .bin file and not the .bin.gz file as that one can only be used on very recent builds.

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: openhab MQTT connection lost

#14 Post by zupy666 » 21 Aug 2020, 19:56

TD-er wrote: 19 Aug 2020, 21:59 See here: https://github.com/letscontrolit/ESPEasy/releases
I just checked one of the latest builds and in there is the ESP_Easy_mega_20200812_hard_SONOFF_POW_4M1M.bin
So you should be possible to OTA to one of the newer builds for Sonoff POW units.

N.B. when upgrading from an older build, only use the .bin file and not the .bin.gz file as that one can only be used on very recent builds.
I performed an FW upgrade to "ESPEasy_ESP82xx_mega-20200812". Nevertheless, I have noticed that the mqtt connection continues to be lost from time to time.
Maybe some other idea?
thx

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: openhab MQTT connection lost

#15 Post by ThomasB » 21 Aug 2020, 20:26

I performed an FW upgrade to "ESPEasy_ESP82xx_mega-20200812". Nevertheless, I have noticed that the mqtt connection continues to be lost from time to time.
Maybe some other idea?
1. This problem might be related to specific module hardware.
Check all your devices to see which are affected by the MQTT problem. Please list which ESP8266 modules are affected (module brand and model number).

2. The problem might be related to intermittent weak RF signal conditions.
Temporarily move an affected ESP8266 module so it is within a couple meters of the WiFi router. Does the random lost MQTT connection issue go away?

3. The problem might be related to the power supply. If the problem occurs on modules that use external 5V power then try a different wall wart supply. Avoid cheap wall warts, these tend to be the source of headaches.

4. On the affected devices, have you ever noticed slow page loads when you web browse the various ESPEasy configuration pages?

- Thomas

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: openhab MQTT connection lost

#16 Post by zupy666 » 21 Aug 2020, 21:18

ThomasB wrote: 21 Aug 2020, 20:26
I performed an FW upgrade to "ESPEasy_ESP82xx_mega-20200812". Nevertheless, I have noticed that the mqtt connection continues to be lost from time to time.
Maybe some other idea?
1. This problem might be related to specific module hardware.
Check all your devices to see which are affected by the MQTT problem. Please list which ESP8266 modules are affected (module brand and model number).

2. The problem might be related to intermittent weak RF signal conditions.
Temporarily move an affected ESP8266 module so it is within a couple meters of the WiFi router. Does the random lost MQTT connection issue go away?

3. The problem might be related to the power supply. If the problem occurs on modules that use external 5V power then try a different wall wart supply. Avoid cheap wall warts, these tend to be the source of headaches.

4. On the affected devices, have you ever noticed slow page loads when you web browse the various ESPEasy configuration pages?

- Thomas
Hi Tomas

Answer the questions:
1. Node model: Sonoff pow r2
2. The Internet network consists of two mikrotik routers that have WiFi configured in mesh mode. They are connected to each other with utp.
3. Power supply is thus exempted as the nodes are connected to 230V, ie according to the manufacturer's connection scheme.
4. I didn't notice the slow performance of the gui

Thx for help :)

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: openhab MQTT connection lost

#17 Post by ThomasB » 21 Aug 2020, 21:37

1. Node model: Sonoff pow r2
If the problem only occurs on your Sonoff Pow R2 modules then perhaps this particular Sonoff module is inviting the problem. It could be similar to the WiFi performance issue that is suffered by the Sonoff Basic R2 V1.0 hardware that is running ESPEasy.

Assuming my hunch is correct, the only practical workaround is to try older ESPEasy versions and cherry pick a release that is the most reliable. Or continue using your special rule that reboots the device when the MQTT connection is lost for an extended period.

- Thomas

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: openhab MQTT connection lost

#18 Post by zupy666 » 21 Aug 2020, 21:44

ThomasB wrote: 21 Aug 2020, 21:37
1. Node model: Sonoff pow r2
If the problem only occurs on your Sonoff Pow R2 modules then perhaps this particular Sonoff module is inviting the problem. It could be similar to the WiFi performance issue that is suffered by the Sonoff Basic R2 V1.0 hardware.

Assuming my hunch is correct, the only practical workaround is to try older ESPEasy versions and cherry pick a release that is the most reliable. Or continue using your special rule that reboots the device when the MQTT connection is lost for an extended period.

- Thomas
Sonoff Basic R2 is crucial to me. However, the same problem occurs with the NodeMCU ESP8266 v1, but I did not notice this with the Wemos D1.

Until I find out, a special rule will stay alive :)
Thx for Help

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: openhab MQTT connection lost

#19 Post by ThomasB » 21 Aug 2020, 23:21

However, the same problem occurs with the NodeMCU ESP8266 v1, but I did not notice this with the Wemos D1.
My installation uses OpenHab2 MQTT and has some Lolin NodeMCU V3 devices that utilize the MQTT broker. They all have the mega-20200222 [Testing] release. I haven't encountered lost MQTT connections with any of my NodeMCUs.

Below is a screenshot of my typical controller settings (for comparison to your configuration):

espeasy_mqtt.jpg
espeasy_mqtt.jpg (113.62 KiB) Viewed 14937 times
- Thomas

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: openhab MQTT connection lost

#20 Post by zupy666 » 22 Aug 2020, 06:44

This is my OH2 configuration. And a correction of the previous post I have NodeMCU ESP8266 v3 not v1.
OH_mqtt.PNG
OH_mqtt.PNG (49.43 KiB) Viewed 14914 times

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: openhab MQTT connection lost

#21 Post by ThomasB » 22 Aug 2020, 19:27

Our controller settings are similar. However, I'm using the mega-20200222 [Testing] release (ESP_Easy_mega-20200222_test_ESP8266_4M1M_VCC.bin) on my NodeMCU devices. This combination has been stable/reliable.

- Thomas

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: openhab MQTT connection lost

#22 Post by zupy666 » 22 Aug 2020, 19:55

I'm using the ESP_Easy_mega_20200812_normal_ESP8266_4M1M.bin and just checked the connection status of NodeMCU and Sonoff POW R2 to which I updated FW. Only one of the Sonoff POW R2 disconnected, all others have been online for the last 24 hours.
I also monitored the entire IoT network traffic, but I did not find anything strange in the relationship with Sonoff POW R2, which lost mqtt connection. :shock: :( :ugeek:

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: openhab MQTT connection lost

#23 Post by TD-er » 22 Aug 2020, 19:57

Try with sending Gratuitous ARP packets (Tools => Advanced, almost at the bottom of the page)

zupy666
Normal user
Posts: 15
Joined: 18 Nov 2017, 20:09

Re: openhab MQTT connection lost

#24 Post by zupy666 » 22 Aug 2020, 20:11

TD-er wrote: 22 Aug 2020, 19:57 Try with sending Gratuitous ARP packets (Tools => Advanced, almost at the bottom of the page)
All nodes with the above mentioned FW have an active additional option you mention “Periodical send Gratuitous ARP”.

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: openhab MQTT connection lost

#25 Post by ThomasB » 22 Aug 2020, 21:01

From your comments it seems that you have confirmed the only affected node is the Sonoff POW R2. And maybe just one in particular. Details like this give you a place to concentrate the debugging.

Also, I think it would be useful to log the RSSI so you can review signal strength before and after the MQTT disconnects.

- Thomas

TD-er
Core team member
Posts: 8736
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: openhab MQTT connection lost

#26 Post by TD-er » 22 Aug 2020, 22:17

Maybe also try to do a ping to the host that's disconnecting?

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests