MQTT in OH3.2 cannot get it running

hello wolfgang,

the content of my /etc/mosquitto/mosquitto.conf is:

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /run/mosquitto/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

password_file /etc/mosquitto/passwd
allow_anonymous false

mosquitto (2.0.11-1)

if i would like to open the logfile, I get a error:
[ Error reading /var/log/mosquitto/mosquitto.log: Permission denied ]

EDIT: My foult! If I open with root it works.
here the content of the logfile

1640291369: mosquitto version 2.0.11 starting
1640291369: Config loaded from /etc/mosquitto/mosquitto.conf.
1640291369: Starting in local only mode. Connections will only be possible from clients running on this machine.
1640291369: Create a configuration file which defines a listener to allow remote access.
1640291369: For more details see https://mosquitto.org/documentation/authentication-methods/
1640291369: Opening ipv4 listen socket on port 1883.
1640291369: Opening ipv6 listen socket on port 1883.
1640291369: mosquitto version 2.0.11 running
1640291496: New connection from 127.0.0.1:38668 on port 1883.
1640291496: New client connected from 127.0.0.1:38668 as openHAB3 (p2, c1, k60, u'MichkasMQTTserver').
1640291519: Client openHAB3 disconnected.
1640293170: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1640294971: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1640296772: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1640298573: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1640298943: mosquitto version 2.0.11 terminating
1640298943: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1640298943: mosquitto version 2.0.11 starting
1640298943: Config loaded from /etc/mosquitto/mosquitto.conf.
1640298943: Opening ipv4 listen socket on port 1883.
1640298943: Opening ipv6 listen socket on port 1883.
1640298943: mosquitto version 2.0.11 running
1640298944: New connection from 192.168.178.227:57248 on port 1883.
1640298944: Client <unknown> disconnected, not authorised.
1640298944: New connection from 192.168.178.225:49825 on port 1883.
1640298944: New client connected from 192.168.178.225:49825 as DVES_975D88 (p2, c1, k30, u'openhabian').
1640298946: New connection from 192.168.178.221:52233 on port 1883.
1640298946: Client <unknown> disconnected, not authorised.
1640298949: New connection from 192.168.178.15:52870 on port 1883.
1640298949: Client <unknown> disconnected, not authorised.
1640298949: New connection from 192.168.178.223:62382 on port 1883.
1640298949: Client <unknown> disconnected, not authorised.
1640298951: New connection from 192.168.178.224:55398 on port 1883.
1640298951: New client connected from 192.168.178.224:55398 as DVES_975D89 (p2, c1, k30, u'openhabian').
1640298954: New connection from 192.168.178.222:55171 on port 1883.
1640298954: Client <unknown> disconnected, not authorised.
1640298955: New connection from 192.168.178.227:57249 on port 1883.
1640298955: Client <unknown> disconnected, not authorised.
1640298957: New connection from 192.168.178.221:56452 on port 1883.
1640298957: Client <unknown> disconnected, not authorised.
1640298960: New connection from 192.168.178.15:64566 on port 1883.
1640298960: Client <unknown> disconnected, not authorised.
1640298960: New connection from 192.168.178.223:52654 on port 1883.
1640298960: Client <unknown> disconnected, not authorised.
1640298965: New connection from 192.168.178.222:49766 on port 1883.
1640298965: Client <unknown> disconnected, not authorised.
1640298966: New connection from 192.168.178.227:57250 on port 1883.

Bit of a clue there; I think ‘localhost’ skips password checks.

Thanks Wolfgang, you have helped me a lot.
Now I have everything up and running.

With this tip it worked.

Guys what does that mean now?
Is the usage of localhost not a solution or is that listener 1883 the better solution?

Otherwise it looks like this is a kind of design fault, right?

hello boris,

does using localhost work for you for devices outside your broker?
for me with localhost the binding itself worked, so the broker thing in OH3, but my devices in the house and MQTT.fx could not connect.

Wolfgang wrote that by default mosquitto no longer listen the ethernet interface. for whatever reason that was set.
With the line “listener 1883” in mosquitto.conf the ethernet interface is liesten again.
here it is also described at mosquitto: Migrating from 1.x to 2.0 | Eclipse Mosquitto

I also think it is a mistake to make such a change. 0815 users like me install mosquitto as usual and then look for errors in their own stuff. Because openhabian and mosquitto have always worked directly.
Anyway, it was a big frustration at first. because I could not see any difference between the configurations of my old system and my new one.

Ah OK, so I will change again localhost to the real IP and add “listener 1883” to the mosquitto.conf file.
I didn’t check yesterday if the broker really connects to the devices.

localhost will work for you as long as all MQTT network traffic is local on your OH host. As soon as you have other devices that would like to talk/listen to your MQTT broker this ( localhost ) will not work.

Thanks Wolfgang,
Didn´t try yet to find my already existent tasmota devices with setoption19 1 configuration.
These devices are all in HomeAssistant mode.
Do I now need to install the HomeAssitant MQTT component additionally, exclusively or how does that work now in OH3? Do I even need the “standard” MQTT broker?
And what is now with my Shellies using the MQTT mode (in Shelly Config) how to catch these devices?

Hmmm, doesn´t want to moan but am I allone in thinking OH3 isn´t really better here?

In general, nothing has functionally changed between OH2 and OH3 when it comes to MQTT, except now you need to have an external MQTT broker installed as the internal broker present in OH2 was removed in OH3.

I don’t think anything has been advertised which suggests OH3 is ‘better’ than OH2 when it comes to MQTT?

Your OP problem comes as a result of configuration of Mosquitto itself, which has nothing to do with openHAB. They recently made some breaking changes which have been linked in this thread. Unfortunately in this space there’s a lot of things to try and keep track of!

Unfortunately this is my first step in OH3.
I was waiting to update from 2.5 cause I thought “give them some time …” Was I wrong?

Basically I agree to what you are writing, but I am a Enthusiast and want to use a SmartHome
solution what offers me an easy access to a really important functionality like MQTT.

To make the MQTT story short
Somehow you need to figure out that you have to install Mosquitto not in mainUI but openhabian-config.
Then back in settings you have to install the broker, but which one?
After that you manually have to edit the mosquitto.conf, is it running now, No it still isn´t…
You know what I mean? Again I don´t want to moan, I am an Enthusiast and still enjoying OH

Just a note on this: you’re not installing a broker in this step - you’re setting up a bridge from OH3 to your external MQTT broker so that the two can talk to each other.

And as @rossko57 says, install the one which does not have System in the name.

See this post for the basics, written before the change to Mosquitto v2 on vanilla Raspberry Pi OS (not openhabian):

Thanks hafniumzinc

This Documentations you linked definitely helps :slight_smile:

I am now trying to catch the tasmotas (all in setoption19 1), they don´t appear.
Maybe I better do a restart first after I installed the transformations now

I configuration manually so have never used auto discovery, but make sure you have the correct transformations installed in openHAB. From the documentation:

The HomeAssistant MQTT requires two transformations to be installed:

JINJA-Transformations
JSONPath-Transformations
These can be installed under Settings->Addons->Transformations

Here’s a post you may have come across when searching the forum:

Exactly what I have done but these homeassistant items are not coming up yet
When I press “SCAN” in order to identify devices
I can see in the log an error by the broker, but the broker is ONLINE

Seems still to be something wrong in setup?

That log tells you exactly what’s wrong in the yellow bit: your IP address in your bridge configuration is not valid. Remove the :s

EDIT: Actually, did you write an IP address into the ID field of your configuration? That’s not valid either. How did you configure this? Via the UI?

Yes in the UI, first I used localhost what worked to get it ONLINE, after that I have added “listener 1883” in mosquitto.conf, and changed localhost to the real IP (no :s here) still ONLINE.
But I cannot leave the IP field empty in the UI, it is required

Somewhere in an OH configuration you have:

192.168.2.223:s

That is what the log is complaining about.

Note that ONLINE in OH doesn’t mean it’s successfully communicating with the MQTT broker, or that the MQTT broker is actually online. It merely means (simplistically) that the configuration of your Bridge has passed some internal testing.

This is somehow disappointing :frowning:
In my config there is no :s doesn´t matter
I deleted the binding, the bridge and
reinstalled mosquitto
reinstalled the binding
reinstalled the bridge

Log shows now

Restartet PI
and again it states that somewhere a :s is used, but it isn´t
Can I check it in the config files, which?

Did a fresh OH setup and follwed the documentation attached.
Added “listener 1883” in mosqitto.conf.

So far no error in the Log.
Later I will try to put a tasmota device in setoption19 1 mode, and see if this will come up

Just added JSONPath transformation and Jinja Transformation as well - restart