[SOLVED] Mqtt 1.13 legacy with oh 2.4.0 not working tried everything

  • Platform information:

    • Hardware:Raspberry PI 3 B+
    • OS: Openhab 2.4.0 (Fresh New Setup)
  • Issue:
    Mqtt Not started, but no commands are observed in openhab log…
    I am trying to simply simulate using dummy switch as show in below item file.
    Legacy 1.x Binding Installed from paperui
    Mosquitto mqtt installed from sudo openhabian-config

Configuration is as below
livingroom.items

Switch MQTT_Test "Testing..." { mqtt="<[broker:testing/mqtt/topic:state:default], >[broker:testing/mqtt/back-topic:command:*:default]" }

Using MQTT FX publishing on below topic with payload “ON” / “OFF” nothing shows up in openhab.log or events.log

testing/mqtt/topic

Openhab Logs shows no error

2019-05-19 09:16:17.586 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel

2019-05-19 09:16:17.638 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Asia/Calcutta'.

2019-05-19 09:16:17.670 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Location set to '22.44030830534578,70.08164521108743'.

2019-05-19 09:16:17.679 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'en_IN'.

2019-05-19 09:16:33.096 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'livingroom.items'

2019-05-19 09:16:40.288 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007

2019-05-19 09:16:41.383 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'main.sitemap'

2019-05-19 09:16:43.536 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.31.122:8080

2019-05-19 09:16:43.549 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.31.122:8443

2019-05-19 09:16:44.036 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.

2019-05-19 09:16:44.050 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection '<broker>'

2019-05-19 09:16:46.147 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui

2019-05-19 09:16:46.374 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin

mqtt.cfg (/var/lib/openhab2/config/org/openhab)

<broker>.clientId="openhab2"
<broker>.pwd="abcd123"
<broker>.url="tcp://192.168.31.122:1883"
<broker>.user="openhabian"
service.pid="org.openhab.mqtt"

/etc/openhab2/services/mqtt.cfg

#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
<broker>.url=tcp://192.168.31.122:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
<broker>.clientId=openhab2

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false

# Optional. User id to authenticate with the broker.
<broker>.user=openhabian

# Optional. Password to authenticate with the broker.
<broker>.pwd=abcd123

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>

I am hitting my head on wall, but this thing is not working.

I also tried Cleaning Cache and all other Suggestion available in community. even Re-Installed Openhab2 but still same. What could be possibly wrong ?

because your mqtt.cfg syntax is wrong:

try broker instead of <broker>

broker.url=tcp://192.168.31.122:1883

(also for all the other occurrences)

I changed to following

#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
broker.url=tcp://192.168.31.122:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
broker.clientId=openhab2

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false

# Optional. User id to authenticate with the broker.
broker.user=openhabian

# Optional. Password to authenticate with the broker.
broker.pwd=abcd123

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>

But i am getting continuous error now.

2019-05-19 10:43:59.463 [WARN ] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to '<broker>' was lost: Connection lost : ReasonCode 32109 : Cause : null

2019-05-19 10:43:59.468 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restoring connection to broker '<broker>'

2019-05-19 10:44:09.478 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection '<broker>'

2019-05-19 10:44:09.510 [WARN ] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'broker' was lost: Connection lost : ReasonCode 32109 : Cause : null

2019-05-19 10:44:09.516 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restoring connection to broker 'broker'

2019-05-19 10:44:19.523 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'

2019-05-19 10:44:19.558 [WARN ] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to '<broker>' was lost: Connection lost : ReasonCode 32109 : Cause : null

2019-05-19 10:44:19.563 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restoring connection to broker '<broker>'

2019-05-19 10:44:29.574 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection '<broker>'

2019-05-19 10:44:29.602 [WARN ] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'broker' was lost: Connection lost : ReasonCode 32109 : Cause : null

2019-05-19 10:44:29.614 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restoring connection to broker 'broker'

2019-05-19 10:44:39.622 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'

2019-05-19 10:44:39.652 [WARN ] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to '<broker>' was lost: Connection lost : ReasonCode 32109 : Cause : null

2019-05-19 10:44:39.658 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restoring connection to broker '<broker>'

Anything else to try ? :thinking:

Stop openHAB, delete /var/lib/openhab2/config/org/openhab/mqtt.config, restart openHAB.
Make sure all clients connected have different client id’s.

1 Like

Thanks sihui

Changed to broker in all instances. and delete /var/lib/openhab2/config/org/openhab/mqtt.config and rebooted openhab server everything working now.

I have

<broker>.url=tcp://192.168.31.122:1883

thing working in old version. I think in new version “broker” is required.

1 Like

In every documentation on the planet that I know of the “<…>” syntax is used to symbolize placeholders. We do this here as well. A placeholder is as the name suggests to be replaced by a value that is valid in that context. The corresponding documentation usually restricts values. We do this as well: Only latin ascii characters are allowed for broker connection ids (no “<”, no “>”).

The tl;dr: Please read the documentation.

1 Like