question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[mqtt] Textual configuration results in flaky connection status

See original GitHub issue

Expected Behavior

Changing a thing configuration file should not break the some things.

Current Behavior

Changing a thing configuration file, where items are already linked to channels (possibly not the root cause for the issue), results in errors, there the configured things are not able use the MQTT client.

2018-12-16 12:14:11.446 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mqtt.things'

==> mosquitto/mosquitto.log <==
1544958851: Client paho439851773078352 disconnected.

==> openhab2/openhab.log <==
2018-12-16 12:14:11.529 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to 'x.x.x.x' with clientid paho481440911850144 and file store '/var/lib/openhab2/mqtt/x.x.x.x'

==> openhab2/events.log <==
2018-12-16 12:14:11.541 [hingStatusInfoChangedEvent] - 'mqtt:broker:MosquittoMqttBroker' changed from ONLINE to OFFLINE
2018-12-16 12:14:11.542 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs01' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2018-12-16 12:14:11.542 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs03' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2018-12-16 12:14:11.543 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs04' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2018-12-16 12:14:11.543 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs06' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2018-12-16 12:14:11.544 [hingStatusInfoChangedEvent] - 'mqtt:broker:MosquittoMqttBroker' changed from ONLINE to OFFLINE
2018-12-16 12:14:11.544 [me.event.ThingUpdatedEvent] - Thing 'mqtt:broker:MosquittoMqttBroker' has been updated.
2018-12-16 12:14:11.556 [hingStatusInfoChangedEvent] - 'mqtt:broker:MosquittoMqttBroker' changed from OFFLINE to ONLINE
2018-12-16 12:14:11.558 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs04' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2018-12-16 12:14:11.559 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs01' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2018-12-16 12:14:11.562 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs06' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2018-12-16 12:14:11.562 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs03' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2018-12-16 12:14:11.564 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs02' changed from UNINITIALIZED to INITIALIZING
2018-12-16 12:14:11.566 [me.event.ThingUpdatedEvent] - Thing 'mqtt:broker:MosquittoMqttBroker' has been updated.
2018-12-16 12:14:11.568 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs02' changed from INITIALIZING to OFFLINE (COMMUNICATION_ERROR): java.lang.Exception: No MQTT client
2018-12-16 12:14:11.575 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs05' changed from UNINITIALIZED to INITIALIZING
2018-12-16 12:14:11.578 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs05' changed from INITIALIZING to OFFLINE (COMMUNICATION_ERROR): java.lang.Exception: No MQTT client
2018-12-16 12:14:11.583 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs07' changed from UNINITIALIZED to INITIALIZING
2018-12-16 12:14:11.585 [hingStatusInfoChangedEvent] - 'mqtt:topic:SonoffPs07' changed from INITIALIZING to OFFLINE (COMMUNICATION_ERROR): java.lang.Exception: No MQTT client

Full configuration example for this is at [https://community.openhab.org/t/using-sonoff-power-switches-with-tasmota-firmware-and-openhab2-mqtt2-binding/](Using Sonoff Power Switches with Tasmota firmware and openHAB2 MQTT2 binding).

Possible Solution

Based on a discussion on [https://community.openhab.org/t/reliability-of-binding-mqtt/59646/26](Reliability of binding-mqtt) the issue seems to be related to a timing problem while reloading the configuration. At the time, where the things are loaded and assigned to the bridge, the bridge is not fully connected or in ONLINE state.

Steps to Reproduce (for Bugs)

Not 100% sure. Please check the configuration on https://community.openhab.org/t/using-sonoff-power-switches-with-tasmota-firmware-and-openhab2-mqtt2-binding/](Using Sonoff Power Switches with Tasmota firmware and openHAB2 MQTT2 binding). I don’t know, if this is reproducable for now.

Your Environment

  • Ubuntu 18.04 Virtual Machine (VMware ESX), with openHAB unstable repository.
  • openhab2 (2.4.0~S1461-1)
  • bundle:list | grep “Eclipse SmartHome MQTT” 229 | Active | 80 | 0.10.0.201812141650 | Eclipse SmartHome MQTT Binding 230 | Active | 80 | 0.10.0.201812141650 | Eclipse SmartHome MQTT Thing Binding 238 | Active | 80 | 0.10.0.201812141650 | Eclipse SmartHome MQTT Transport Bundle

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
boc-tothefuturecommented, Dec 27, 2018

Workaround: Move the line that defines your MQTT broker into a separate file and don’t touch that file while openHAB is running. Alternative: Define your Broker Thing in the UI and use it from your text configuration files.

@davidgraeff - Can you provide a simple example? It is unclear to me how to do that since I define my thing inside of the Bridge which defines the broker?

For example, my config looks like this:

Bridge mqtt:broker:mosquitto [ host="mosquitto.aocboc", secure=false, clientID="openhab", username="user", password="pass" ]
{
    Thing topic brultech {
    Channels:
        Type number : volts "Current Voltage" [ stateTopic="/house/energy/249808_volts" ]
    }
}

If I define the broker in a broker.thing file how do I avoid redefining it in the mqtt.thing file? In the blog post they are broken out, but the mqtt.thing defines parameters for the broker again.

1reaction
davidgraeffcommented, Dec 23, 2018

JSON transformations

You mean the JSONPATH transformation? Works perfectly and is automatically tested and documented as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MQTT Client and Broker and MQTT Server and Connection ...
The MQTT connection is always between one client and the broker. Clients never connect to each other directly. To initiate a connection, the ......
Read more >
Paho Python MQTT Client - Working with Connections
A look at client connections and the Paho MQTT client. Includes examples of good and failed connections and re-connections.
Read more >
MQTT Collector Overview (version 22) - Canary Community
The 'Status' screen displays all configured 'Connection Groups' within the collector. Each connection group consists of at least one MQTT server ...
Read more >
MQTT's Capabilities in an Unstable Net- work - CORE
First connection's status is checked. If it's disabled, vector holding messages coming from the MQTT broker is cleared if it's not empty. Then...
Read more >
Reliability of binding-mqtt - #20 by David_Graeff
Hi Guys, I'm struggling arround with the MQTT Binding since two ... “MQTT: Textual configuration results in flaky connection status” or so.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found