MQTT in OH3.2 cannot get it running

Openhabian3.2, Pi4

I do have a fresh OH3.2 installation and just trying now to install MQTT.
Cause I can´t find Mosquitto I think it is the MQTT binding, so it is installed.
Now Trying to add the broker and can see two entries “MQTT broker” and “MQTT System broker”
I assume it is the first entry “MQTT broker”.
Now added the IP of the PI and also added User/PW openhabian/openhabian

The broker remains Offline with communication error.

What is wrong, did I select the wrong broker or binding?

You need to install Mosquitto MQTT broker separate, outside of openHAB.

Thanks,
Just Mosquitto via Openhabian-config?
Do I need JSONPATH as well as I used in OH2?

Only if you want to use JSONPATH again. It is still an optional add-on.

Definitely don’t use that for anything. It needs removing from OH3.

yes.

Deinstalled the MQTT binding
Installed Mosquitto via Openhabian-Config (no error, done)
restarted -
But how to proceed, is the broker now online?
I cannot add a thing - do I need now to install a further binding for mqtt?

You need to have a broker like mosquitto in your network.
To use MQTT in OH you need to use the MQTT binding.
After configuration of MQTT binding it connects as client to the broker.

To check if the broker is running and if it is listening on localhost only or on ehternet as well run

sudo netstat -tulpn | grep -i mosquitto

If just 127.0.0.1 resp. :::1 is being shown then it only listens to localhost ( messages that are exchanged on the system ). If 0.0.0.0 is show it listens to messages on the ethernet interface.

Not connecting!

netstat shows

tcp        0      0 127.0.0.1:1883          0.0.0.0:*               LISTEN      617/mosquitto
tcp6       0      0 ::1:1883                :::*                    LISTEN      617/mosquitto

I have installed MQTT broker and added the local IP from the PI as well User/PW openhabian/openhabian still not connecting

and this it shows in “Code”

UID: mqtt:broker:8e5e2667f7
label: MQTT Broker
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: true
  password: openhabian
  keepAlive: 60
  qos: 0
  reconnectTime: 60000
  host: 192.168.2.223
  secure: false
  certificatepin: true
  lwtRetain: true
  enableDiscovery: true
  username: openhabian

This command

ls -l /var/log /var/log/mosquitto 2>/dev/null |grep mosquitto

shows

drwxr-xr-x  1 mosquitto root                4096 Dec 23 20:28 mosquitto
/var/log/mosquitto:
-rw------- 1 mosquitto mosquitto 3416 Dec 23 20:28 mosquitto.log

Hello!
I have the same problem. I wanted to completely rebuild my OH3.0 system with OH3.2 and I can’t get MQTT to work properly.
The MQTT broker Thing goes to “online” when I enter localhost or 127.0.0.1 as broker, but with the address of the Raspberry itself 192.168.178.2 I also get a communication_error.
Also with MQTT.fx I can’t connect to the broker no matter what I set…
I am using a raspberr pi 3 b+ with the latest openhabian built. I installed mosquitto via openhabian-config. several times. sometimes with password, sometimes without. then I tried to install it via apt install. Added another user and password… All this does nothing…

Solution found !

You need to change the IP in the MQTT Broker to “localhost” instead the IP.
For whatever reason the IP doesn´t work.

I´ve got the solution in the German forum

What is the content of your /etc/mosquitto/mosquitto.conf configuration file ?
Which version of mosquitto is installed: dpkg -l | grep -i mosuqitto
Does the content of the log file /var/log/mosquitto/mosquitto.log show any information that helps to analyse the root cause ?

Your broker needs to listen on the ethernet interface which is not the default for newer versions.
Try to add listener 1883 in the mosquitto.conf configuration file.

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?