How to monitor all Mosquitto MQTT traffic in Hass.io?

In my old AIO install, I could run mosquitto_sub -v -t '#' in the command line to view all messages passing through the broker in real time. This was immensely useful in debugging my setup. Without access to the command line in Hass.io, what’s a good method of monitoring the broker traffic? Thanks

1 Like

adding this line to logger.yaml did wonders for me, refine for any level you need, up to debug:

homeassistant.components.mqtt: warn

I’m using zanzito.

On activities

I installed MQTTLens on my MacBook last night but for some reason the extension was completely messed up and unusable (giant fonts and crazy formatting). I just tried it on my work computer and it seems to be fine. I’ll give this another look tonight. Thanks!

Cheers, this will help. What’s the best method to monitor the logging in real time?

Thanks for the suggestion, unfortunately, I don’t have any android devices.

If you have the ssh addon installed, you can just ssh in and run mosquitto_sub as you used to.

just view the log, either in the front-end interface under the developers tools/info, or load the log in a viewer like console (Mac)

So, I decided to see if I could actually see all of my MQTT traffic. So, I have issued the following command in the terminal window, I am using the built in broker.

➜  ~ mosquitto_sub -h 192.168.1.6 -v -t sensor/# -d

I am only getting one result and it is non stop. I do not even have a device with that or a similar mac address according to my router…

Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT
Client mosqsub|3727-a0d7b954-t sending CONNECT

I do have one ESP8266 device that is working properly on the network locally and one device on a remote network that is also working properly. I expected to see them connect and also to see them publish states.

What am I doing wrong?

Thanks Matt

I did realize that my username and password were not included, so…

mosquitto_sub -h 192.168.1.6 -u wwwwwww -P xxxxxxxxx -v -t 'sensor/#' -d

Also tried:

mosquitto_sub -h 192.168.1.6 -u wwwwwww -P xxxxxxx -v -t '#' -d

Still the same result. I do notice that when I reset one of my devices and force it to establish a new connection that the list above pauses for a couple of seconds.

Trying to get a handle on this before I have to troubleshoot a device.

Matt

Thanks @NotoriousBDG. Glad to see this still works. I just had to change the syntax a little. This is what worked for me in Hass.io:

mosquitto_sub -h 192.168.1.5 -u mqtt-username -P mqtt-password -v -t '#'

For some reason this only works if I use “-h 192.168.1.5” and doesn’t work with “localhost” or “127.0.0.1” Any idea why this is?

4 Likes

the specific address being needed vs. using the generic loopback not working is likely an artifact of the fact that hass is running in another docker container and doesn’t have access to the host-wide loopback interface.

probably because of the way networking in Docker works? Localhost in the SSH docker container would reference the container you are in.

but how do you see ALL messages without subscribing ?

?

Just subscribe to #

3 Likes

wow really, how do i not know this, nice one, appreciated

And where are the logs?

Developer Tools —> Logs

If you have installed Mosquitto broker add-on, You can go in Settings, Devices, choose Mqtt, and Configure. Then you have the publish or subscribe.