Openhab 3 Mqtt Broker Problems

Hello,
I installed openhab 3 and in openhab-config I installed Mqtt without of problems.
Now I try to into OH to add the mqtt-broker via mqtt-binding. But can’t get it online. Everytime he shows communication error.
What’s the right way to do?
Thank you

your code goes here

What MQTT broker are you using? Mosquitto? Can you show us that it is actually running?

Thank you for your reply. Now I startet a fresh OH3 installation and now its´s working fine. Last time I booting OH3 from a USB SSD - do you know if that could be the problem.

Is it nessesary to use SSD at OH3, because of the SD crash?

Changing to OH3 shouldn’t matter - risks are still the same as they ever where. I guess the only difference is that OH3 has persistence on by default, so it is probably going to write more to your SD card.

There are quite a few people here who run from an SSD - I’m fairly certain our resident Australian @denominator does, and he uses MQTT.

Another option might be to use openHABian, which will use ZRAM to reduce SD card fatigue.

Most importantly though: use a good quality SD card, and a good quality power supply, and make sure not to just remove power from the Pi - always shut down first.

1 Like

Ok, thanks.
Now, the problem is back: After changing the Network to wlan and do a reboot, the MQTT isn´t running anylonger :frowning:

I´m using openhabian, but when I try to use ZRAM via config, it shows the error

Which bit? The MQTT broker? The Bridge Thing? The device (Generic) Things?

If you want to use ZRAM then follow those instructions on your screen to read the DEBUG guide, which will give you more instructions!

The MQTT Broker isn´t working - the bridge thing shows communication error in red and when I try to connect via MQTT.fx it shows "unable to connect to server.

The DEBUG guide didn´t help me so much :frowning:

What do you get when you run sudo /bin/systemctl status mosquitto.service

image

Also can you post the mosquitto.log file sudo cat /var/log/mosquitto/mosquitto.log

Rpi 3b+ Msata SSD openHAB 2 latest main system for now but moving everything to a new home. Rpi 4 8 gig ram running 64bit os openHAB 3 on SD card

MQTT is your friend and the centre of my control system for heaps of things.

**[13:07:27]** **openhabian@openHABianDevice**:**~**$ sudo /bin/systemctl status mosquitto.service

[sudo] password for openhabian:

**Warning:** The unit file, source configuration file or drop-ins of mosquitto.service changed on disk. Run 'systemctl daemon-reload' to reload units.

**●** mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker

Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)

Drop-In: /etc/systemd/system/mosquitto.service.d

└─override.conf

Active: **failed** (Result: exit-code) since Sat 2020-12-26 12:49:49 CET; 17min ago

Docs: man:mosquitto.conf(5)

man:mosquitto(8)

Process: 867 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf **(code=exited, status=1/FAILURE)**

Main PID: 867 (code=exited, status=1/FAILURE)

Dec 26 12:49:49 openHABianDevice systemd[1]: mosquitto.service: Service RestartSec=100ms expired, scheduling restart.

Dec 26 12:49:49 openHABianDevice systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.

Dec 26 12:49:49 openHABianDevice systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker.

Dec 26 12:49:49 openHABianDevice systemd[1]: **mosquitto.service: Start request repeated too quickly.**

Dec 26 12:49:49 openHABianDevice systemd[1]: **mosquitto.service: Failed with result 'exit-code'.**

Dec 26 12:49:49 openHABianDevice systemd[1]: **Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.**

**[13:07:36]** **openhabian@openHABianDevice**:**~**$ sudo cat /var/log/mosquitto/mosquitto.log

cat: /var/log/mosquitto/mosquitto.log: No such file or directory

**[13:09:59]** **openhabian@openHABianDevice**:**~**$

Run
sudo systemctl daemon-reload

sudo /bin/systemctl restart mosquitto.service

sudo /bin/systemctl status mosquitto.service

I have the same error like @Superpedro. This is what I get fot the given commands.

[13:27:05] openhabian@openHABianDevice:~$ sudo /bin/systemctl status mosquitto.service
● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
   Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-12-26 13:27:06 CET; 7s ago
     Docs: man:mosquitto.conf(5)
           man:mosquitto(8)
  Process: 6089 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
 Main PID: 6089 (code=exited, status=1/FAILURE)

Dec 26 13:27:06 openHABianDevice systemd[1]: mosquitto.service: Service RestartSec=100ms expired, scheduling restart.
Dec 26 13:27:06 openHABianDevice systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.
Dec 26 13:27:06 openHABianDevice systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker.
Dec 26 13:27:06 openHABianDevice systemd[1]: mosquitto.service: Start request repeated too quickly.
Dec 26 13:27:06 openHABianDevice systemd[1]: mosquitto.service: Failed with result 'exit-code'.
Dec 26 13:27:06 openHABianDevice systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.

Can you also check the mosquitto log file

IF there is not one there try adding one.

chown mosquitto /var/log/mosquitto/mosquitto.log

Thanks for this hint. Ther was no directory /var/log/mosquitto nor a logfile. I created them both and changed the fileowner to mosquitto as you suggested.
chown mosquitto /var/log/mosquitto/mosquitto.log
After that I could run the commands from above and resart the mosquitto service.

[14:26:04] openhabian@openHABianDevice:/var/log/mosquitto$ sudo /bin/systemctl status mosquitto.service
● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
   Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-12-26 14:26:04 CET; 6s ago
     Docs: man:mosquitto.conf(5)
           man:mosquitto(8)
 Main PID: 8178 (mosquitto)
    Tasks: 1 (limit: 2182)
   CGroup: /system.slice/mosquitto.service
           └─8178 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Dec 26 14:26:04 openHABianDevice systemd[1]: Starting Mosquitto MQTT v3.1/v3.1.1 Broker...
Dec 26 14:26:04 openHABianDevice systemd[1]: Started Mosquitto MQTT v3.1/v3.1.1 Broker.

just discovered that still the binding shows a communication error but I proved with mqtt.fx that the broker is running.

[quote="I created them both and changed the fileowner to mosquitto as you suggested.
[/quote]

How could I create them and how could I change the fileowner?

mkdir /var/log/mosquitto
touch /var/log/mosquitto/mosquitto.log

Did you setup a password?

yes when I installed mosquitto with the config tool

Can you post your broker code

UID: mqtt:broker:RPI4
label: MQTT Broker RPI4
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: false
  keepAlive: 60
  clientid: bbea88c4-bcd2-4eb3-bc01-49d14720018b
  secure: false
  certificatepin: false
  password: pleasework
  qos: 0
  reconnectTime: 60000
  host: 192.168.1.248
  lwtRetain: true
  username: openhabian
  enableDiscovery: true

Brilliant!

1 Like

so this was my config so far:

UID: mqtt:broker:openHAB
label: MQTT Broker
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: true
  keepAlive: 60
  clientid: 3b875904-088a-49da-8300-72ccd1447766
  qos: 0
  reconnectTime: 60000
  host: localhost
  secure: false
  certificatepin: true
  lwtRetain: true
  enableDiscovery: true

with adding username and password it connects now to the broker again

UID: mqtt:broker:openHAB
label: MQTT Broker
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: true
  keepAlive: 60
  clientid: 4b8ce49d-81fe-410a-bd13-73973849eb25
  secure: false
  certificatepin: true
  password: openhabian
  qos: 0
  reconnectTime: 60000
  host: localhost
  lwtRetain: true
  enableDiscovery: true
  username: openhabian

still I didn’t try to restart the rpi yet. Will do that as a next step. Also I discovered this thread with similar problems described for oh2: Openhabian - Mosquitto MQTT failed to start - #41 by mstormi

1 Like