Home assistant not connecting to mosquitto mqtt

Hi,

Currently i am going from an rpi3 to a rpi4.
I have put al my data from one HASSIO to another and so far so good. But when i try to get mqtt up and running it seems that something goes wrong with the connection that hassio should make with the broker.

All the other devices can connect without a problem but my homeassistant not.
I see a connection from 172.30.32.1 as i understand internally .

I installed the add on as explained than started it up, created a user and then the integration was discovered as mqtt and set up.

What am i missing here?

my ip from hassio is : 192.168.1.43, you can see it disconnecting.

1589558713: Opening ipv4 listen socket on port 1883.
1589558713: Opening ipv6 listen socket on port 1883.
1589558713: Opening websockets listen socket on port 1884.
1589558713: Warning: Mosquitto should not be run as root/administrator.
1589558713: New connection from 192.168.1.206 on port 1883.
[INFO] found MQTTuser on Home Assistant
1589558714: New client connected from 192.168.1.206 as ESP8266Client-6a1 (p2, c1, k15, u'MQTTuser').
1589558714: New connection from 172.30.32.1 on port 1883.
[INFO] found homeassistant on local database
1589558715: New client connected from 172.30.32.1 as auto-A2D6F015-95C8-607E-CDBC-51FB49D989C3 (p2, c1, k60, u'homeassistant').
1589558716: New connection from 192.168.1.50 on port 1883.
1589558716: New client connected from 192.168.1.50 as arduinoClient (p2, c1, k15, u'MQTTuser').
1589558720: New connection from 192.168.1.220 on port 1883.
1589558720: New client connected from 192.168.1.220 as DVES_15BC47 (p2, c1, k10, u'MQTTuser').
1589558720: New connection from 192.168.1.222 on port 1883.
1589558720: New client connected from 192.168.1.222 as DVES_E0D320 (p2, c1, k30, u'MQTTuser').
1589558720: New connection from 192.168.1.111 on port 1883.
1589558720: New connection from 192.168.1.101 on port 1883.
1589558720: New connection from 192.168.1.185 on port 1883.
1589558720: New client connected from 192.168.1.111 as sonoff_werkplaats_zolder (p2, c1, k30, u'MQTTuser').
1589558720: New client connected from 192.168.1.101 as DVES_8DE1A6 (p2, c1, k10, u'MQTTuser').
1589558720: New client connected from 192.168.1.185 as DVES_7579DD (p2, c1, k10, u'MQTTuser').
1589558720: New connection from 192.168.1.240 on port 1883.
1589558720: New client connected from 192.168.1.240 as DVES_5B6375 (p2, c1, k10, u'MQTTuser').
1589558720: New connection from 192.168.1.51 on port 1883.
1589558720: New connection from 192.168.1.157 on port 1883.
1589558720: New client connected from 192.168.1.51 as arduino_garage (p2, c1, k15, u'MQTTuser').
1589558720: New client connected from 192.168.1.157 as DVES_A81FD9 (p2, c1, k10, u'MQTTuser').
1589558726: New connection from 192.168.1.43 on port 1883.
1589558726: Socket error on client <unknown>, disconnecting.
1589558741: New connection from 192.168.1.43 on port 1883.
1589558741: Socket error on client <unknown>, disconnecting.
1 Like

well other devices are connecting ok to your mqtt server exept the 192.168.1.43 device

i d identify that device and check if the wifi connection is stable

Thank you but i don’t think that is the problem. Because my RPI4 with hassos is connected via Ethernet and the connection 192.168.1.43 is the hassio device itself that is trying to connect to the mqtt broker add on.

I am thinking to go for a full reinstall of the sd card, but that might be a little extreme.

oops my bad didnt fully read :stuck_out_tongue:

client <unknown>

You didn’t do this did you?

1 Like

No it is called MQTTuser .
I have set up already a few rpi’s with home assitant.
This time i want to go to a newer rpi but with mqtt is goes wrong.

Also the ip adres is fixed to 192.168.1.43 via this way: https://community.home-assistant.io/t/guide-connecting-pi-with-home-assistant-os-to-wifi-or-other-networking-changes/98768

But not wifi of course, i believe this was successful for i can connect to home assistant via this ip adress.

I am thinking there might be something left in a file somewhere that might have to be deleted.
I already deleted the add on, integration and user, rebooted an started all over but no effect.
I also have declared it in my config but and deleted the others but with no effect.

Have you previously created an access control list (ACL)?

If using the home assistant created user you don’t need these files:

/share/mosquitto/acl.conf
/share/mosquitto/accesscontrollist

no i haven’t used ACL lists before so i do not think that could be the problem.

nothing in homeassistant logs ?

Add this to configuration.yaml :

logger:
  default: error
  logs:
    homeassistant.components.mqtt: debug

Save, restart HA, let HA run for a minute of 5 and then post your home-assistant.log

1 Like

Ok i added this to my log and i can see that for all my mqtt devices that are coded in yaml the subscriptions are done and the data is recieved.
Also auto discovery works fine.

Under is a snippet of the log.

2020-05-18 15:27:35 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on arduino_alarmcentrale/status: b'online'
2020-05-18 15:27:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on ESP8266/thisDevID/Afstand1: b'62.00'
2020-05-18 15:27:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on ESP8266/thisDevID/Afstand2: b'60.00'
2020-05-18 15:27:45 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on arduino_alarmcentrale/status: b'online'
2020-05-18 15:27:52 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on ESP8266/thisDevID/Afstand1: b'62.00'
2020-05-18 15:27:52 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on ESP8266/thisDevID/Afstand2: b'61.00'
2020-05-18 15:27:55 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on arduino_alarmcentrale/status: b'online'
2020-05-18 15:28:02 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on ESP8266/thisDevID/Afstand1: b'62.00'
2020-05-18 15:28:02 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on ESP8266/thisDevID/Afstand2: b'61.00'

This i can see in the system log of the superviser:
Might be a link but i don’t see it.

20-05-18 13:32:10 INFO (SyncWorker_13) [supervisor.docker.interface] Restart homeassistant/raspberrypi4-homeassistant
20-05-18 13:32:14 ERROR (MainThread) [supervisor.homeassistant] Error on call http://172.30.32.1:8123/api/states/binary_sensor.snapshots_stale: Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused]
20-05-18 13:32:14 ERROR (MainThread) [supervisor.api.proxy] Error on API for request states/binary_sensor.snapshots_stale
20-05-18 13:32:45 INFO (MainThread) [supervisor.homeassistant] Detect a running Home Assistant instance

So everything seems to work but stil the weird error in the mosquitto log… i am puzzeld
The fixed ip is that of my pi 4 with hassio

1589809389: New connection from 192.168.1.43 on port 1883.
1589809389: Socket error on client <unknown>, disconnecting.
1589809404: New connection from 192.168.1.43 on port 1883.
1589809404: Socket error on client <unknown>, disconnecting.
1589809419: New connection from 192.168.1.43 on port 1883.
1589809419: Socket error on client <unknown>, disconnecting.

I now have successfully overhauled everything to the RPI4 and all is working, but still i get the weird log in mosquitto.
But everything with mqtt is working fine. It seems like a bug…

I believe i have found the answer to the problem today, i was configuring another new HA and found the same error after starting node red. I seemed that node red indeed had the correct ip for mqtt but no login an password so that was causing the error.

Thx everyone for helping.

1 Like

On that topic
Is there any comprehensive tutorial on how to set mosquitto up with a tasmotized entity?
Thank you