0

Home Assistant Mosquitto Tasmota Device Socket Error

I have just completed a fresh install of Home Assistant OS 6.4 (core-2021.9.7 upgraded to 2021.10.0, supervisor-2021.09.6) on a Raspberry Pi 4, together with Mosquitto 6.0.1 configured as an add-on. As far as I can tell that installation seemed to work fine.

But the problem I'm having is when trying to configure my first Tasmoto (9.5.0) device via MQTT. I'm getting a

1633680390: New connection from 192.168.1.28 on port 1883.
1633680390: Socket error on client <unknown>, disconnecting.

This error seems to crop up quite a lot in other posts, and most times boils down to an authentication problem. But no matter what I do, I can't seem to fix the problem, or even have an affect on it. I always get the same error.

Does anyone have any ideas what the problem might be, or more importantly how I can diagnose the problem? While the Tasmoto device seems to be working OK, I can't rule that out as the source of the problem.

  1. Installed HA following the instructions described here: https://www.home-assistant.io/installation/raspberrypi/ on a Pi 4 and went through the onboarding process and this step seems to have completed fine.

  2. I installed Mosquito as an MQTT Broker as a Home Assistant Add-on using the process described here: https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md, and this seemed to work OK too.

The MQTT configuration looks like this, but I've tried it with logins: [] and anonymous: true as well.

logins:
  - username: username
    password: password
customize:
  active: false
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false
anonymous: false
  1. I've configured the MQTT Device, a Localbytes pre-flashed tasmota plug with the following MQTT confirmation information.

Tasmota MQTT Config 1 Tasmota MQTT Config 2 Tasmota MQTT Config 3

192.168.1.32 is the address of the Home Assistant node. 192.168.1.28 is the Tasmota device. I've used SetOption19 1 to make the Tasmota device discoverable.


The log files look like this:

  1. MQTT Broker via HA
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] mosquitto.sh: executing... 
[09:02:51] INFO: SSL is not enabled
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] nginx.sh: executing... 
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[09:02:52] INFO: Starting NGINX for authentication handling...
[09:02:52] INFO: Starting mosquitto MQTT broker...
1633680172: mosquitto version 1.6.12 starting
1633680172: |-- *** auth-plug: startup
[09:02:53] INFO: Successfully send discovery information to Home Assistant.
[09:02:53] INFO: Successfully send service information to the Supervisor.
1633680172: Config loaded from /etc/mosquitto/mosquitto.conf.
1633680172: Loading plugin: /usr/share/mosquitto/auth-plug.so
1633680172:  ├── Username/password checking enabled.
1633680172:  ├── TLS-PSK checking enabled.
1633680172:  └── Extended authentication not enabled.
1633680172: Opening ipv4 listen socket on port 1883.
1633680172: Opening ipv6 listen socket on port 1883.
1633680172: Opening websockets listen socket on port 1884.
1633680172: Warning: Mosquitto should not be run as root/administrator.
1633680172: mosquitto version 1.6.12 running
1633680172: New connection from 127.0.0.1 on port 1883.
1633680172: Socket error on client <unknown>, disconnecting.
1633680177: New connection from 172.30.32.1 on port 1883.
401: Unauthorized1633680178: Socket error on client <unknown>, disconnecting.
1633680179: New connection from 192.168.1.28 on port 1883.
401: Unauthorized1633680179: Socket error on client <unknown>, disconnecting.
1633680200: New connection from 192.168.1.28 on port 1883.
1633680200: Socket error on client <unknown>, disconnecting.
1633680231: New connection from 192.168.1.28 on port 1883.
1633680231: Socket error on client <unknown>, disconnecting.
  1. From the Tasmota Device..
09:21:12.302 MQT: Attempting connection...
09:21:12.324 MQT: Connect failed to 192.168.1.32:1883, rc 5. Retry in 120 sec
09:23:13.518 MQT: Attempting connection...
09:23:13.542 MQT: Connect failed to 192.168.1.32:1883, rc 5. Retry in 120 sec
09:25:14.541 MQT: Attempting connection...
09:25:14.564 MQT: Connect failed to 192.168.1.32:1883, rc 5. Retry in 120 sec
09:25:54.414 RSL: HASS_STATE = {"Version":"9.5.0(tasmota)","BuildDateTime":"2021-06-17T08:26:35","Module or Template":"LocalBytes PM","RestartReason":"Software/System restart","Uptime":"0T00:20:00","Hostname":"plug1-3601","IPAddress":"192.168.1.28","RSSI":"100","Signal (dBm)":"-50","WiFi LinkCount":1,"WiFi Downtime":"0T00:00:03","MqttCount":0,"LoadAvg":19}
09:25:58.392 RSL: STATE = {"Time":"2021-10-08T09:25:58","Uptime":"0T00:20:04","UptimeSec":1204,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":0,"POWER":"ON","Wifi":{"AP":1,"SSId":"<redacted>","BSSId":"00:50:7F:F1:42:9A","Channel":12,"Mode":"11n","RSSI":96,"Signal":-52,"LinkCount":1,"Downtime":"0T00:00:03"}}
09:25:58.399 RSL: SENSOR = {"Time":"2021-10-08T09:25:58","ENERGY":{"TotalStartTime":"2021-09-29T17:59:48","Total":0.011,"Yesterday":0.000,"Today":0.000,"Period":0,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":232,"Current":0.000}}
09:27:15.528 MQT: Attempting connection...
1

Without seeing the actual /etc/mosquitto/mosquitto.conf that is being generated and passed to mosquitto this is only a guess.

But it looks like mosquitto is being configured to use TLS (you appear to be passing in a cert & private key). The mosquitto log output shows that only 2 listeners are being started. The first on 1883 and the second on 1884 for websockets.

This implies that they are both using TLS but you haven't enabled any TLS in the Tasmota config.

1
  • Hi, I'm afraid that wasn't it. After a fresh install it works OK, with the same set-up as described above. I think the issue was with the MQTT integration step, which I might have tried before configuring the add-on. If you do the add-on first and then configure the MQTT integration it worked for me OK the 2nd time.
    – P Burke
    Oct 11 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.