Mqtt broker unable to be reached

Hi everyone. Since last update of hassio 0.91… and the mosquitto official add on version 4.1 my system breaked down. All my tasmotized devices are looking to conect the mqtt broker but could not.
I configure the add on with this settings:

{
“logins”: [
{
“username”: “my username on the tasmotazed sonoffs”,
“password”: “my password on the tasmotized sonoffs”
}
],
“anonymous”: false,
“quiet_logs”: true,
“customize”: {
“active”: true,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”

of course the mosquitto ACCESS CONTROL LISTS (ACLS) is created as displayed on the addon

This is my log on mqqtt add on

1556145310: Socket error on client cliente36, disconnecting. 1556145310: Socket error on client cliente8, disconnecting. 1556145310: Socket error on client cliente40, disconnecting. 1556145310: Socket error on client cliente16, disconnecting. 1556145310: Socket error on client cliente22, disconnecting. 1556145310: Socket error on client cliente28, disconnecting. 1556145310: Socket error on client cliente38, disconnecting. 1556145310: Socket error on client cliente2, disconnecting. 1556145310: Socket error on client cliente37, disconnecting. 1556145310: Socket error on client cliente4, disconnecting. 1556145310: Socket error on client cliente41, disconnecting. 1556145310: Socket error on client cliente34, disconnecting. 1556145310: New connection from 192.168.1.245 on port 1883. 1556145310: New connection from 192.168.1.246 on port 1883. 1556145310: New connection from 192.168.1.244 on port 1883. 1556145310: New connection from 192.168.1.218 on port 1883. 1556145310: New connection from 192.168.1.221 on port 1883. 1556145310: New connection from 192.168.1.223 on port 1883. 1556145310: New connection from 192.168.1.248 on port 1883. 1556145310: New connection from 192.168.1.235 on port 1883. 1556145310: New connection from 192.168.1.243 on port 1883. 1556145310: New connection from 192.168.1.237 on port 1883. 1556145310: New connection from 192.168.1.214 on port 1883. 1556145310: New connection from 192.168.1.225 on port 1883. 1556145310: New connection from 192.168.1.234 on port 1883. 1556145310: New connection from 192.168.1.236 on port 1883. 1556145310: New connection from 192.168.1.240 on port 1883. 1556145310: New connection from 192.168.1.232 on port 1883. 1556145310: New connection from 192.168.1.228 on port 1883. 1556145310: New connection from 192.168.1.247 on port 1883. 1556145310: New connection from 192.168.1.242 on port 1883. 1556145310: New connection from 192.168.1.213 on port 1883. 1556145310: New connection from 192.168.1.217 on port 1883. 1556145310: New connection from 192.168.1.239 on port 1883. 1556145310: New connection from 192.168.1.233 on port 1883. 1556145310: New connection from 192.168.1.226 on port 1883. 1556145310: New connection from 192.168.1.252 on port 1883. 1556145310: New connection from 192.168.1.215 on port 1883. 1556145310: New connection from 192.168.1.253 on port 1883. 1556145310: New connection from 192.168.1.216 on port 1883. 1556145310: New connection from 192.168.1.251 on port 1883. 1556145310: New connection from 192.168.1.212 on port 1883. 1556145310: New connection from 192.168.1.219 on port 1883. 1556145310: New connection from 192.168.1.231 on port 1883. 1556145310: New connection from 192.168.1.238 on port 1883. 1556145310: New connection from 192.168.1.241 on port 1883. 1556145310: New connection from 192.168.1.244 on port 1883. 1556145310: New connection from 192.168.1.245 on port 1883. 1556145310: New connection from 192.168.1.235 on port 1883. 1556145310: New connection from 192.168.1.221 on port 1883. 1556145310: New connection from 192.168.1.246 on port 1883. 1556145310: New connection from 192.168.1.248 on port 1883. 1556145310: New connection from 192.168.1.218 on port 1883. 1556145310: New connection from 192.168.1.223 on port 1883. 1556145310: New connection from 192.168.1.243 on port 1883. 1556145310: New connection from 192.168.1.230 on port 1883. [INFO] found daniel on local database 1556145311: New client connected from 192.168.1.245 as cliente10 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145312: New client connected from 192.168.1.246 as cliente9 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145313: New client connected from 192.168.1.244 as cliente11 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145314: New client connected from 192.168.1.218 as cliente35 (c1, k10, u’daniel’). [WARN] Not found daniel on local database 1556145315: Socket error on client <unknown>, disconnecting. [INFO] found daniel on local database 1556145316: New client connected from 192.168.1.223 as cliente30 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145317: New client connected from 192.168.1.248 as cliente7 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145318: New client connected from 192.168.1.235 as cliente20 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145319: New client connected from 192.168.1.243 as cliente12 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145320: New client connected from 192.168.1.237 as cliente18 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145321: New client connected from 192.168.1.214 as cliente39 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145322: New client connected from 192.168.1.225 as cliente29 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145323: New client connected from 192.168.1.234 as cliente21 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145324: New client connected from 192.168.1.236 as cliente19 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145325: New client connected from 192.168.1.240 as cliente15 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145326: New client connected from 192.168.1.232 as cliente23 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145328: New client connected from 192.168.1.228 as cliente26 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145329: New client connected from 192.168.1.247 as cliente8 (c1, k10, u’daniel’). [WARN] Not found daniel on local database 1556145330: Socket error on client <unknown>, disconnecting. [INFO] found daniel on local database 1556145331: New client connected from 192.168.1.213 as cliente40 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145332: New client connected from 192.168.1.217 as cliente36 (c1, k10, u’daniel’). [INFO] found daniel on local database 1556145333: New client connected from 192.168.1.239 as cliente16 (c1, k10, u’daniel’).

when i go to integrations an choose mqqt configure i put all the data Host, username,password and when i executed it came with this :slight_smile:

Unable to connect to the broker.

I have my pi assigned the ip 192.168.1.200 as always.

the extrange thing is that when i leave DHCP enable and don´t choose an static ip for the PI sometime i am eble to configure the mqqtt on integrations and back to control my lights but after a while everything go nuts again.

My router is an asus AC 5300 with aimesh along with AC 88u, I have try them without the aimesh configuration and other options on the router menus but no luck.

tasmota ver 6.5 core 2.3 and every sonoff switch could be reached and control by its IP adress inserted on the browser.

any idea whats wrong???

HEEEELLLLPPP

I am seeing something similar, and it’s not just from tasmota devices, it is also occurring with ESPEasy devices. Nothing is connecting to the MQTT broker, or at least not staying connected. It started earlier today and I hadn’t made changes in days. The broker was 4.1, just to try something I upgraded to 4.2 and rebooted the entire hassio box. Same issue.

In the broker log I’m seeing entries like this…

[INFO] found mqttiot on Home Assistant
1556149927: Client DVES_3B9424 already connected, closing old connection.
1556149927: Socket error on client DVES_3B9424, disconnecting.
1556149927: New client connected from 192.168.7.123 as DVES_3B9424 (c1, k10, u’mqttiot’).
[INFO] found mqttiot on Home Assistant
1556149929: Client DVES_E88772 already connected, closing old connection.
1556149929: Socket error on client DVES_E88772, disconnecting.
1556149929: New client connected from 192.168.7.169 as DVES_E88772 (c1, k10, u’mqttiot’).
[INFO] found mqttiot on Home Assistant
1556149931: Client DVES_A0121B already connected, closing old connection.
1556149931: Socket error on client DVES_A0121B, disconnecting.
1556149931: New client connected from 192.168.7.130 as DVES_A0121B (c1, k10, u’mqttiot’).

Try restarting home assistant. I’ve had this problem occasionally since updating to HA 0.91 and v4.1 of the addon. A restart of the HA server fixes it for me.

I wish it were as simple as restarting something. I’ve restarted HASS more than once, and the mosquitto broker more than once, and the entire box exactly once. Now running hassio 91.4 and mosquitto add-on 4.2, was running 91.3 and 4.1 when this first started being a problem today.

Another data point, I can use mosquitto_sub (from ssh addon) to connect and it sees all the retained mqtt messages and seems to stay connected. However, if try manually publishing something using mosquitto_pub (in another ssh window), it times out after about a minute and says “Error: Unknown error.”

All the mqtt devices are reporting connection failed (tasmota and ESPEasy). When I tried to connect from a windows mqtt app, it also is unable to connect.

HASS itself is also reporting being unable to connect to the broker in /config/home-assistant.log

2019-04-24 19:45:59 WARNING (Thread-2) [homeassistant.components.mqtt] Disconnected from MQTT (1). Trying to reconnect in 32 s
2019-04-24 19:46:32 WARNING (Thread-2) [homeassistant.components.mqtt] Disconnected from MQTT (1). Trying to reconnect in 64 s
2019-04-24 19:55:48 WARNING (Thread-2) [homeassistant.components.mqtt] Disconnected from MQTT (1). Trying to reconnect in 1 s

What is really odd, is that when this started happening, I hadn’t made any changes at all for a days. It was working, then all of sudden it wasn’t.

Have you set up access control lists? Mosquito update 4.1 - ACL messages in logs

This is the ACL I have, pretty straight forward. /share/mosquitto/accesscontrollist

user mqttiot
topic #
user homeassistant
topic #

and the /share/mosquitto/acl.conf

acl_file /share/mosquitto/accesscontrollist

it was working fine, and all of a sudden it wasn’t. I can certainly make mistakes when playing with the configs, but I hadn’t touched in days then today it just stopped working. Maybe there is a way to get more detailed logs from mosquitto.

I was just checking you had one. Your ACL is fine.

Is mqttiot a local user or a HA user?

Just HA users, no local. My mqtt config is quite simple

{
“logins”: ,
“anonymous”: false,
“quiet_logs”: true,
“customize”: {
“active”: true,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
}

Couple of other things then:

  1. make sure you have no mqtt: configuration in your configuration file.
  2. Check the integration is still there

and finally try copying your broker config, reinstall the broker, paste your config back and restart it.

topic readwrite #

I think at least that’s how mine reads

no other mqtt: in the configuration.yaml, however, integration for mqtt says:

Aborted Only a single configuration of MQTT is allowed

which is very odd as I can’t see where it would be seeing another mqtt configuration. I’m heading to bed as it’s midnight where I am, but will pick it up tomorrow. I also tried uninstalling/re-installing mqtt add-on which didn’t changing anything. I can always just start with a new image on another sd card and load the backup and see if that makes a difference.

as far as “topic readwrite #”, my issue is that the devices can’t even connect to the server, they’re not even to the point of looking at topics yet, they just loop trying to connect.

Thanks for the ideas…to be continued.

I’m having problems with Mosquitto as well, including warnings about multiple mqtt configurations and constant connects/disconnects. Will experiment tonight and see if I can find a solution.

I have a work around for my mqtt issue. The home assistant login I was using for mqtt devices was being ignored by the mqtt add-on. As soon as I add a local login to the mqtt config and restarted mqtt, all my devices connected. It doesn’t seem to matter if the identical login/pw exists in both the local mqtt config and as a home assistant login, as long as it is in the local config everything works. I tried deleting the home assistant login and re-recreating it, made no difference, mqtt ignored it. This is not the way it was working in the past nor how it is described in the mqtt add-on page. Maybe a bug or something else odd in my overall configuration.

What I had before:

{
  "logins": [],
  "anonymous": false,
  "quiet_logs": true,
  "customize": {
    "active": true,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

What I changed it to (pw redacted):

{
  "logins": [
    {
      "username": "mqttiot",
      "password": "MYPASSWORD"
    }
  ],
  "anonymous": false,
  "quiet_logs": true,
  "customize": {
    "active": true,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

In my case I have mosquitto add on already configure the way you state it works for you but still nothing. I even did new clean install on new SD card.

The thing is so simple

  1. New clean intall
  2. Install the configurator add on
  3. Install and configure samba add on
  4. Install mqtt add on. Adding on loggins user and password. Customized active changed to true. And save it
  5. Create new user with my name daniel and the password and change from administrator to user
  6. Create mosquitto folder with the two folders inside as instructed
  7. Start mosquitto add on
  8. Go to integrations
  9. Over there there are two mqtt integrations the embebed mqtt server that not use and on the long list I go mqtt and push configure option
  10. Put the PI address 192.168.1.200. The port 1883, the user and password of my tasmotized sonoffs (witch is the same that I have on home assistant and also on the local configuration of the add on)
  11. Push done button and instead of creation the configuration of the mqqt broker and showed it on integrations it comes with
    UNABLE YO CONNECT TO THE BROKER

Sometimes if creates my the broker but after a restart or two all the sonoffs lost the connection and system don’t work. I suspected from the router configuration but I coul reach the hassio system without trouble by 192.168.1.200:8123 so pi host is reachable.

I am lost

@Daniel_Correa_Parada
For your step 9, I used the mqtt integration near the top that was auto detected as opposed to the one further down in the long list. I also tried the one on the long list and HA wasn’t able to connect to the broker like yours.

The integration is only concerned with HA talking to the broker. Your sonoff devices should connect rather the integration is working or not. I suggest getting the sonoffs reliably working with the broker before even trying to turn on the integration.

Test just the MQTT broker by itself and get that working first. This helped me in debug by eliminating all the variables external the raspberry pi running HA, as well as the HA application itself. Here are the general steps

  • Install the ssh add-on and get that working, I use the putty application to connect over ssh. It takes a little work to, but I’ve found ssh quite helpful with various debugging efforts.

  • delete any integrations of HA with MQTT, but it doesn’t sound like you have any working anyway. Take your sonoffs off line initially.

  • open a ssh terminal window and use the following to subscribe to all mqtt topics (changing the user and password as appropriate):
    mosquitto_sub -h 192.168.1.200 -u YOURUSER -P YOURPASS -v -t "#"

  • Leave this window open with the command running. Even if this works, you won’t likely see any output as there won’t be any MQTT messages unless some devices are connecting and sending messages. The mqtt log should show the connection was established.

  • open a second ssh window to the box and try sending some messages, for example:
    mosquitto_pub -h 192.168.1.200 -u YOURUSER -P YOURPASS -t "testing/mymessage" -m "hello world"

  • If everything is working on the mqtt broker, you will see the messages sent from the second ssh window display on the first ssh window. If it works, then the issue is likely in the sonoffs or your network, or HA integration.

  • If this is working, then put your sonoffs online and see if they connect and stay connected. Watch the first ssh window, you should see periodic messages from the sonoff. Connect to the sonoff over a web browsers and turn the switches on/off, you should see the messages go by. Watch the mqtt broker log along the way for any odd happenings. Try restarting the broker and make sure the sonoffs reconnect, also watch the sonoff console window for any errors or issues. Leave it like this for a while to see if it’s stable.

1 Like

I will try that this week end about the mqtt Integrations I just try both separetelly but it didn’t work either

Anybody can resolved it?, i am lost

In my case still no idea was wrong need time to rethink about what the problems come from any idea is appreciated