Up to a couple weeks ago, all my ESPEasy devices were working fine but suddenly they are all failing to connect to my local MQTT brokers (using either the hostname or the IP) with the error:
15651: MQTT : Intentional reconnect
15713: MQTT : Failed to connect to broker
All devices work fine when connecting to a cloud broker. The version of ESPEasy doesn't seem to matter, it happens using
mega-20190805,
mega-20190106,
mega-20181026
What is strange is that the broker (mqttpizw.local) works in all other cases and even works if I take a WeMos running ESPEasy (which won't connect) and flash it with an Arduino sketch doing MQTT. Here are the things that work
Pi -> MQTT -> Pi
------------------------
NR on rosemarypi ——> mqttpizw.local ——> NR (on mac) works
WeMos (ESPEasy) -> MQTT -> Pi
--------------------------------
wemos42 ——> beebotte ——> NR (on mac) works
wemos42 ——> mqttpizw.local ——> NR (on mac) FAILS
wemos42 ——> 192.168.48.102 (mqttpizw.local) ——> NR (on mac) FAILS
wemos33 ——> mqttpizw.local ——> NR (on mac) FAILS
NOTE: wemos33 was now flashed with an Arduino sketch using MQTT pointing at 192.168.48.102
WeMos (arduino) -> MQTT -> Pi
————————————————
wemos33 ——> 192.168.48.102 (mqttpizw.local) ——> NR (on mac) works
I thought it might have been a firmware update to my apple base station, but I downgradded the firmware and still have the problem.
Any thoughts/suggestions.
[SOLVED] MQTT - Failed to connect to broker
Moderators: grovkillen, Stuntteam, TD-er
-
- Normal user
- Posts: 87
- Joined: 19 Jul 2018, 01:48
[SOLVED] MQTT - Failed to connect to broker
Last edited by dampa on 09 Aug 2019, 23:19, edited 1 time in total.
-
- Normal user
- Posts: 1385
- Joined: 17 Jun 2018, 20:41
- Location: USA
Re: MQTT - Failed to connect to broker
Several ESPEasy devices breaking at the exact same time seems unlikely. So, I agree something has likely changed in the broker's configuration (which has impacted the chosen controller settings used in the ESPEasy devices).
Some things to try can be found in this discussion:
viewtopic.php?t=5691
- Thomas
Some things to try can be found in this discussion:
viewtopic.php?t=5691
- Thomas
-
- Normal user
- Posts: 87
- Joined: 19 Jul 2018, 01:48
Re: MQTT - Failed to connect to broker
Just found another clue. I went and looked at the mosquitto log on the pi (/var/log/mosquitto/mosquitto.log) and I see this
1565375291: New connection from 192.168.48.42 on port 1883.
1565375291: Socket error on client <unknown>, disconnecting.
1565375321: New connection from 192.168.48.29 on port 1883.
1565375321: Socket error on client <unknown>, disconnecting.
1565375351: New connection from 192.168.48.23 on port 1883.
1565375351: Socket error on client <unknown>, disconnecting.
Every one of those IP are a wemos with ESPEasy running
Is this a mqtt version issue? the Pi is running
pi@mqttpizw:/var/log/mosquitto $ mosquitto -v
1565382066: mosquitto version 1.4.10 (build date Wed, 13 Feb 2019 00:45:38 +0000) starting
How do I sepcify a client id?
1565375291: New connection from 192.168.48.42 on port 1883.
1565375291: Socket error on client <unknown>, disconnecting.
1565375321: New connection from 192.168.48.29 on port 1883.
1565375321: Socket error on client <unknown>, disconnecting.
1565375351: New connection from 192.168.48.23 on port 1883.
1565375351: Socket error on client <unknown>, disconnecting.
Every one of those IP are a wemos with ESPEasy running
Is this a mqtt version issue? the Pi is running
pi@mqttpizw:/var/log/mosquitto $ mosquitto -v
1565382066: mosquitto version 1.4.10 (build date Wed, 13 Feb 2019 00:45:38 +0000) starting
How do I sepcify a client id?
-
- Core team member
- Posts: 9923
- Joined: 01 Sep 2017, 22:13
- Location: the Netherlands
Re: MQTT - Failed to connect to broker
What timeout value is being used on the broker side?
It used to be 10 sec as default for Mosquito, but I guess it could have been lowered in the settings?
You can test by setting a LWT in some MQTT controller and look at the broker to see if the ESPeasy node is considered to be disconnected.
For these kind of tests, I normally use a separate topic and a MQTT viewer like MQTTbox. But any viewer is fine as long as you can see the live data.
It used to be 10 sec as default for Mosquito, but I guess it could have been lowered in the settings?
You can test by setting a LWT in some MQTT controller and look at the broker to see if the ESPeasy node is considered to be disconnected.
For these kind of tests, I normally use a separate topic and a MQTT viewer like MQTTbox. But any viewer is fine as long as you can see the live data.
-
- Normal user
- Posts: 1385
- Joined: 17 Jun 2018, 20:41
- Location: USA
Re: MQTT - Failed to connect to broker
Code: Select all
Socket error on client <unknown>, disconnecting.
- Thomas
-
- Normal user
- Posts: 87
- Joined: 19 Jul 2018, 01:48
Re: MQTT - Failed to connect to broker
TD-er, ThomasB
Thank you for looking at this the problem was with the mosquitto configuration file. I got a copy of dynamicdave's configuration file and once I put that in, it started working. I was not using userid and passwords and I think the missing 'allow_anonymous true' might have been the issue.
this is what I get for updating systems without a complete backup
Here is the working mosquitto configuraton file:
Thank you for looking at this the problem was with the mosquitto configuration file. I got a copy of dynamicdave's configuration file and once I put that in, it started working. I was not using userid and passwords and I think the missing 'allow_anonymous true' might have been the issue.
this is what I get for updating systems without a complete backup

Here is the working mosquitto configuraton file:
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
user mosquitto
max_queued_messages 200
message_size_limit 0
allow_zero_length_clientid true
allow_duplicate_messages false
listener 1883
autosave_interval 900
autosave_on_changes false
persistence true
persistence_file mosquitto.db
allow_anonymous true
log_dest file /var/log/mosquitto/mosquitto.log
# include_dir /etc/mosquitto/conf.d
-
- Normal user
- Posts: 1385
- Joined: 17 Jun 2018, 20:41
- Location: USA
Re: [SOLVED] MQTT - Failed to connect to broker
Glad to hear you solved it.
- Thomas
- Thomas
Who is online
Users browsing this forum: Anthropic Claude Bot [bot], Bing [Bot], opensiteexplorer.org/dotbot [bot] and 29 guests