Login to mosquitto-broker fails after last update

Guess how I found out :slight_smile:
It might only be possible if you’ve set up the old version with anonymous enabled and then upgrade.

For anyone that needs it, here’s a good videos on setting up the whole thing (though on the old Home Assistant menu version)
https://www.youtube.com/watch?v=dqTn-Gk4Qeo

So I have the default MQTT broker running and am upgraded to 6.12. I had a few devices that did not use a username and password. They have been updated, I have created a default user for MQTT and have what appears to be all of my devices now reporting.

But, my broker logs are full of the following message:
error: received null username, clientid or topic, or access is equal or less than 0 for acl check

What do I have wrong?
Here is my system information:

System Health

version: core-2022.5.3
installation_type: Home Assistant Supervised
dev: false
hassio: true
docker: true
user: root
virtualenv: false
python_version: 3.9.9
os_name: Linux
os_version: 5.10.0-13-amd64
arch: x86_64
timezone: America/Chicago


GitHub API: ok
GitHub Content: ok
GitHub Web: ok
GitHub API Calls Remaining: 5000
Installed Version: 1.24.5
Stage: running
Available Repositories: 1051
Downloaded Repositories: 16


host_os: Debian GNU/Linux 11 (bullseye)
update_channel: stable
supervisor_version: supervisor-2022.05.1
docker_version: 20.10.12
disk_total: 218.1 GB
disk_used: 38.8 GB
healthy: true
supported: true
supervisor_api: ok
version_api: ok
installed_addons: Backup Hassio to Google Drive (1.7.2), Dropbox Sync (1.3.0), Duck DNS (1.14.0), File editor (5.3.3), Log Viewer (0.13.0), RPC Shutdown (2.2), WireGuard (0.6.0), Mosquitto broker (6.1.2), SSH & Web Terminal (10.1.3), Samba share (9.6.1), TasmoAdmin (0.17.0), Glances (0.15.0), Check Home Assistant configuration (3.10.0), DHCP server (1.3.0), Network UPS Tools (0.10.0), Samba Backup (5.0.0), Node-RED (11.1.2), Portainer (2.0.0), Home Assistant Google Drive Backup (0.107.2), SDR to Home Assistant (0.1.13b)


dashboards: 1
resources: 7
views: 15
mode: storage


version: 3.0.4 (8a202d5)
cloud_online: 0 / 0
local_online: 0 / 0

The problem I have is, that I use the login option, but the broker still says it’s an unknown user.

I use the php-mqtt on my server with this configuration:

$mqtt_server   = 'raspberrypi';
$mqtt_port     = 1883;
$clientId = 'heatronic';
$mqtt_username = 'mqtt';
$mqtt_password = '**********';
$clean_session = false;

$mqtt = new MqttClient($mqtt_server, $mqtt_port, $clientId);

$connectionSettings  = new ConnectionSettings();
$connectionSettings
  ->setUsername($mqtt_username)
  ->setPassword($mqtt_password)
  ->setKeepAliveInterval(60)
  ->setLastWillTopic('home/heizung/last-will')
  ->setLastWillMessage('client disconnect')
  ->setLastWillQualityOfService(1);

$mqtt->connect($connectionSettings, $clean_session);

and get this in the log of the mosquitto-broker (all versions):

1652334001: New connection from 192.168.178.7 on port 1883.
1652334001: New client connected from 192.168.178.7 as heatronic (p1, c0, k10).
1652334001: Client heatronic disconnected.

What the hell I’m doing wrong?

Where did you define your username and password?

…and at the settings of the integration

OK, so in the HA user system. Can you try with, say mosquitto_sub ?

what do you mean with “say mosquitto_sub” ?

I mean try logging in with the standard mosquitto_sub commandline.

I don’t know how to do that

image

Well done for something you didn’t know how to do.

So logging in from the localhost doesn’t need any authentication. Same here.

But logging in from another host doesn’t work without username and password (for me anyway).

Do you have another computer you can try this from?

Okay, I have many computers.
But I have no idea how to login from another computer.

mosquitto_sub -h ipaddressofmqttserver -u username -P passwd -v -t "home/+/+"

I do not have the command mosquitto_sub on other computers

apt install mosquitto-clients

I had this problem.
Just updated mosquitto addon to 6.1.2 and HA core from 2022.4.something to 2022.5.3.
After these upgrades no messages to/from HA and zigbee2mqtt.
In the mosquitto log I can see that my z2m user is connecting fine, but in the HA log I can see auth failures for mqtt.
I needed to re-run mqtt configuration and re-enter the password for the mosquitto user I created for HA.
I tested that HA could sub and pub to mqtt then restarted HA and all OK now.
I also needed to restart z2m to get it to (re)publish all sensor values back into HA.

Also for people who dont have a bunch of *nix instances handy, you can also use the windows application http://mqtt-explorer.com/ its good and free

We said he had plenty of other computers, I didn’t contemplate windows! :slight_smile:

:slight_smile: I know eveyone should have a linux vm or two handy to use, or even ubuntu on windows… :scream: but actually that mqtt client is pretty good and useful too.

What do you mean by ‘re-enter the passwork for the mosquitto user I created for HA.’
Thanks