OpenHAB2 will not talk to working MQTT broker - Error no connection

Okay I is stuck…

I have had a working installation for months now but after a recent reboot in order to shift my server, and a routine update on the Linux install, the eventbus communication between OpenHAB2 and the MQTT broker ceased.
I used to see regular messages in the MQTT feed from /openHAB/.
Now I only see the messages posted from other network devices posting to the broker.

The OpenHAB2 broker itself works fine but NO action done within OpenHAB is passed out to the broker

The reason is obvious:
[ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection

Which in turn leads to the following error:
[ERROR] [mqtt.internal.MqttPersistenceService] - Error sending persistency message for … {}
Null … of course

Did permissions change on the MQTT subsystem?

Is it refusing to accept insecure connections now?

I have read, read and re-read all the helps I could find over the last 5 days
I have cleared cache, uninstalled and reinstalled all MQTT related add-ons, etc, etc, etc…
Config files have not changes and been reviewed repeatedly.
There is no password set on the broker and all the other devices on the network happily communicate with it.

Anyone have any suggestions before I start posting config files and error logs?

@Tameion

can you post the contents of the following 7 files plz:

MQTT Binding related:
1) /etc/openhab2/services/mqtt.cfg
2) /var/lib/openhab2/config/org/openhab/mqtt.config

MQTT EventBus related:
3) /etc/openhab2/services/mqtt-eventbus.cfg
4) /var/lib/openhab2/config/org/mqtt-eventbus.config

MQTT Persistence related:
5) /etc/openhab2/persistence/mqtt.persist
6) /etc/openhab2/services/mqtt-persistence.cfg

Mosquitto related:
6) /etc/mosquitto/mosquitto.conf
(or stuff in your /etc/mosquitto/conf.d/)

Why MqttPersistenceService ? do you need it? that’s not the MQTT-EventBus integration.

Okay - sorry for delay - manually typed but double checked for mistooks.

mqtt,cfg

tameion.url=tcp://10.1.1.180:1883
tameion.lwt=Offline

mqtt.config

service.pid="org.openhab.mqtt"
tameion.lwt="Offline"
tameion.url="tcp://10.1.1.180:1883"

mosquitto.conf

pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d

I don’t need persistence but I was planning on being able to query the store like a database for other not OpenHAB projects I have in the workshop that could access the broker.

I can disable while we troubleshoot ?

This file may be of relevance here as I had to use MQTT1 to get the binding to work:

addons.cfg

remote = true
legacy = false
binding = astro,chromecast,exec,mqtt1,network,ntp,systeminfo,tcp1,yahooweather
ui = basic,habmin,habpanel,paper
persistence = mqtt
action = mqtt,telegram
transformation = jsonpath,scale
voice = marytts,voicerss
misc = market,gcal1,openhabcloud,ruleengine

The error(s) that you are getting are because the MQTT Persistence cannot connect to the Broker to store the info based on your mqtt.persist settings.

Can you troubleshoot the OH2<->Broker connectivity by simply adding a demo Switch bound to a topic and publish a message?

Your mqtt.cfg & mosquitto.conf look good
I have additionally: listener 1883 0.0.0.0 on my mosquitto.conf (but you say that the broker is working with other nodes)

If you want to use the MQTT-Event Bus integration, set your stuff in mqtt-eventbus.cfg

MQTT Persistence is used to store the state of selected Items (defined in mqtt.persist)
MQTT EventBus is used to send and/or receive every Command and/or Status to/from the broker

take this guy out!
there is an issue with him :slight_smile:

Yes… I understand the Persistence and Eventbus functionality. I was using this to ‘spy’ on events in the broker and perform actions that OpenHAB2 does not yet have the ability to do on other MQTT enabled applications… until I get around to writing my own plugins (if ever!)

FYI

mqtt-persistence.cfg

broker=tameion
topic=/openHAB/persistence
message=%1$s, %3$s

mqtt.persist

Strategies {
everyHour : “0 0 * * * ?”
default = everyChange
}
Items {

// persist a;; items every hour and on every change

  • : strategy = everyChange, everyHour, restoreOnStartup

// additionally, persist all temperature and weather values every hour
Temperature*, Weather* : strategy = everyHour
}

home.items

Switch tv_manland “Manland Television” [ “Switchable” ] {mqtt=“<[tameion:stat/sonoff_07/POWER:state:default], >[tameion:cmnd/sonoff_05/POWER:command:*:default]” }

So I believe everything looks right — but I still can’t place my finger on the fault!

configs look correct
check: [MQTT with MQTT Action] MQTT Binding will not connect with action installed · Issue #5038 · openhab/openhab1-addons · GitHub

uninstall the MQTT Action Add-on and try again

Take it out. It will cause you more problems than it’s worth.

persistence false
1 Like

by the way: what use case can be solved using MQTT Persistence that cannot be solved using regular MQTT bound Items? (maybe an hourly update of a state of an Item?)

Still no joy… calling it quits for tonight !

It’s 12:40 am here in NZ and I have to teach in the morning…

Thanks for the assist will try again tomorrow night.

1 Like

Well I have come to an impasse… I have checked and compared every log file. Deleted cleared and reloaded broker, etc. No Joy.

Here’s a dump for those interested.

2018-11-27 21:58:05.802 [DEBUG] [.binding.mqtt.internal.MqttActivator] - MQTT binding has been started.
2018-11-27 21:58:05.825 [DEBUG] [org.openhab.binding.mqtt ] - BundleEvent STARTED - org.openhab.binding.mqtt
2018-11-27 21:58:06.116 [DEBUG] [penhab.io.transport.mqtt.MqttService] - Starting MQTT Service…
2018-11-27 21:58:06.141 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler}={service.id=375, service.bundleid=219, service.scope=bundle, event.topics=openhab/, component.name=org.openhab.binding.mqtt.MqttItemBinding, component.id=231} - org.openhab.binding.mqtt
2018-11-27 21:58:06.149 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item RFBridge1_Reachable
2018-11-27 21:58:06.167 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item ‘RFBridge1_Reachable’ : 1 subscribers, 0 publishers
2018-11-27 21:58:06.184 [TRACE] [.internal.MqttGenericBindingProvider] - Starting to load MQTT config for item RFBridge1_STATE
2018-11-27 21:58:06.189 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item ‘RFBridge1_STATE’ : 1 subscribers, 0 publishers
2018-11-27 21:58:06.279 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.mqtt.MqttBindingProvider}={service.id=374, service.bundleid=219, service.scope=bundle, component.name=org.openhab.binding.mqtt.genericbindingprovider, component.id=232} - org.openhab.binding.mqtt
2018-11-27 21:58:06.289 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT: Activating event bus binding.
2018-11-27 21:58:06.292 [DEBUG] [org.openhab.binding.mqtt ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={service.id=377, service.bundleid=219, service.scope=bundle, event.topics=openhab/
, service.pid=org.openhab.mqtt-eventbus, component.name=org.openhab.binding.mqtt.eventbus, component.id=233} - org.openhab.binding.mqtt
2018-11-27 21:58:06.294 [DEBUG] [org.openhab.io.transport.mqtt ] - ServiceEvent REGISTERED - {org.openhab.io.transport.mqtt.MqttService, org.osgi.service.cm.ManagedService}={service.id=373, service.bundleid=224, service.scope=bundle, service.pid=org.openhab.mqtt, component.name=MQTT Connection Service, component.id=246} - org.openhab.io.transport.mqtt
2018-11-27 21:58:06.296 [DEBUG] [org.openhab.io.transport.mqtt ] - BundleEvent STARTING - org.openhab.io.transport.mqtt
2018-11-27 21:58:06.297 [DEBUG] [org.openhab.io.transport.mqtt ] - BundleEvent STARTED - org.openhab.io.transport.mqtt
2018-11-27 21:58:06.300 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Initializing MQTT Event Bus Binding
2018-11-27 21:58:06.301 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Setting up Event Bus State Publisher for topic /openHAB/out/${item}/state
2018-11-27 21:58:06.307 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Setting up Event Bus State Subscriber for topic /openHAB/in/+/status
2018-11-27 21:58:06.308 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Setting up Event Bus Command Publisher for topic /openHAB/out/${item}/command
2018-11-27 21:58:06.310 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - Setting up Event Bus Command Subscriber for topic /openHAB/in/+/command
2018-11-27 21:58:06.312 [DEBUG] [ng.mqtt.internal.MqttEventBusBinding] - MQTT Event Bus Binding initialization completed.
2018-11-27 21:58:06.316 [TRACE] [penhab.io.transport.mqtt.MqttService] - Processing property ‘tameion.lwt’ = Offline
2018-11-27 21:58:06.319 [DEBUG] [penhab.io.transport.mqtt.MqttService] - Setting last will: [class org.openhab.io.transport.mqtt.MqttWillAndTestament] Send ‘null’ to topic ‘Offline’ using qos mode 0
2018-11-27 21:58:06.320 [TRACE] [penhab.io.transport.mqtt.MqttService] - Processing property ‘tameion.url’ = tcp://127.0.0.1:1883
2018-11-27 21:58:06.321 [TRACE] [t.mqtt.internal.MqttBrokerConnection] - url property changed. client will be shut down.
2018-11-27 21:58:06.322 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Closing connection to broker ‘tameion’
2018-11-27 21:58:06.323 [TRACE] [penhab.io.transport.mqtt.MqttService] - Processing property ‘tameion.user’ = nouser
2018-11-27 21:58:06.325 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-11-27 21:58:06.326 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘tameion’
2018-11-27 21:58:06.375 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Creating new client for ‘tcp://127.0.0.1:1883’ using id ‘paho61546320797’ and file store ‘/var/lib/openhab2/tmp/tameion’
2018-11-27 21:58:06.422 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin
2018-11-27 21:58:06.453 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
java.lang.IllegalArgumentException: null
at org.eclipse.paho.client.mqttv3.MqttConnectOptions.validateWill(MqttConnectOptions.java:168) [224:org.openhab.io.transport.mqtt:1.12.0]
at org.eclipse.paho.client.mqttv3.MqttConnectOptions.setWill(MqttConnectOptions.java:158) [224:org.openhab.io.transport.mqtt:1.12.0]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.openConnection(MqttBrokerConnection.java:362) [224:org.openhab.io.transport.mqtt:1.12.0]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.start(MqttBrokerConnection.java:98) [224:org.openhab.io.transport.mqtt:1.12.0]
at org.openhab.io.transport.mqtt.MqttService.updated(MqttService.java:122) [224:org.openhab.io.transport.mqtt:1.12.0]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189) [8:org.apache.felix.configadmin:1.8.16]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152) [8:org.apache.felix.configadmin:1.8.16]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85) [8:org.apache.felix.configadmin:1.8.16]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1479) [8:org.apache.felix.configadmin:1.8.16]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1435) [8:org.apache.felix.configadmin:1.8.16]
at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141) [8:org.apache.felix.configadmin:1.8.16]
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109) [8:org.apache.felix.configadmin:1.8.16]
at java.lang.Thread.run(Thread.java:748) [?:?]

looks to me like… a classic “evil brother” symptom: (/var/lib/openhab2/config/org/openhab/mqtt.config in your case… the evil brother of /etc/openhab2/services/mqtt.cfg :slight_smile:)

add the following line as the first line in your mqtt.cfg

pid:org.openhab.mqtt

Ref: Troubleshooting section of MQTT Binding (v1.11) Getting Started 101

Got it - Thanks!!!

Dam that was a loooooong road to recovery. The evil twin issue sure took a lot of steps to identify, isolate and resolve. Clearing the cache after your last instruction and restarting OH did the job.

I think a big part of my problem was not being patient enough and allowing OH to do its thing before trying another fix.

I have renamed the thread to better identify it for those in similar situations. I think you did a robust job or support - clearer and more focused than most of the other threads I have read in trying to solve this situation.

Now… I’m off to repair the W.A.F. with a bit of grovelling and probably chocolate!

Again thanks heaps for your support.

1 Like