MQTT config under OH2

for mine (delete any commented out lines in txt editor (e.g. notepad or notepad++)

most important line in mqtt.cfg is
OH2MQTT.url=tcp://192.168.1.10:1883

my items look like:

Switch DO_70_4 “Ensuite Fan - manual override [%s]” (Ensuite,Node70,log) {mqtt=">[OH2MQTT:home/rfm_gw/sb/node70/dev19:command:ON:ON],>[OH2MQTT:home/rfm_gw/sb/node70/dev19:command:OFF:OFF]",autoupdate=“true”}
Number Tem_7048 “Roof space 7048 [%.1f °C]” (Roof, HouseData, Node70, All_Temperature,log,temp_chart) {mqtt="<[OH2MQTT:home/rfm_gw/nb/node70/dev48:state:default]"}
Number Tem_7050 “Bathroom temperature 7050 [%.1f °C]” (HouseData, Bathroom, Node70, All_Temperature,log,temp_chart) {mqtt="<[OH2MQTT:home/rfm_gw/nb/node70/dev50:state:default]"}

type removing quote marks from broker name - see mine above

ok, give me 5. :slight_smile:

Note that changing existing keys in mqtt.cfg will need attention as well under /var/lib/openhab2/config to work around issue.

1 Like

getting these errors now
17-01-20 18:15:41.872 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ‘’ was lost: Connection lost : ReasonCode 32109 : Cause : null

broker is up and running. just checked

More of the log. the good news this is the most I have ever seen in the log :smile:

Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146)[186:org.eclipse.paho.client.mqttv3:1.0.2]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_111]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_111]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65)[186:org.eclipse.paho.client.mqttv3:1.0.2]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)[186:org.eclipse.paho.client.mqttv3:1.0.2]

 1 more
2017-01-20 18:20:52.438 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ‘mqttbroker’ was lost: Connection lost : ReasonCode 32109 : Cause : null
2017-01-20 18:20:52.439 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'mqttbroker’
2017-01-20 18:21:02.439 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mqttbroker’
2017-01-20 18:21:02.447 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146)[186:org.eclipse.paho.client.mqttv3:1.0.2]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_111]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_111]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65)[186:org.eclipse.paho.client.mqttv3:1.0.2]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)[186:org.eclipse.paho.client.mqttv3:1.0.2]

 1 more
2017-01-20 18:21:02.447 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ‘’ was lost: Connection lost : ReasonCode 32109 : Cause : null
2017-01-20 18:21:02.448 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker ''
2017-01-20 18:21:02.451 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker ‘mqttbroker’ on topic 'control/SW010101/SW2/state’
2017-01-20 18:21:02.453 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker ‘mqttbroker’ on topic 'control/SW010101/SW2/state’
2017-01-20 18:21:02.454 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker ‘mqttbroker’ on topic 'control/SW010101/SW3/state’
2017-01-20 18:21:02.455 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker ‘mqttbroker’ on topic ‘control/SW010101/SW3/state’
^C

delete file: /var/lib/openhab2/config/org/openhab/mqtt.config and let openHAB 2 reload your /etc/openhab2/services/mqtt.cfg

2 Likes

Woooot
 your the man
up and running. I owe you big time.
Where do you live?
I owe you a coffee

1 Like

I think that @WayneStronach helped you much more by assisting you in fixing your mqtt.cfg file :slight_smile:
I just put the finishing touch with 1 small error :wink:

true, so I owe you both LOL

1 Like

This thread helped me a lot. I was also stuck with two different mqtt config files and finally I solved it.
Thanks a lot guys and keep up the good work.

Folks, I have been struggling with a similar issue. Have not been able to resolve it in the last week of trying.

I have OH2 running on a Raspberry Pi3. All fine. I am now trying to publish my ZWAVE events to IBM Watson’s IOT (mqtt) broker.

Watson cloud environment has been set up properly.
I can connect to the MQTT broker using a standalone client on my Mac (MQTTBox). Through that, I could verify that the URL / Username / Password are all ok. Connecting to Watson from the RPI3 however keeps failing with the following message:

11:39:54.082 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'watsoniot’
11:39:55.439 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
Not authorized to connect (5)
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:24)[216:org.openhab.io.transport.mqtt:1.9.0]
at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:773)[216:org.openhab.io.transport.mqtt:1.9.0]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:110)[216:org.openhab.io.transport.mqtt:1.9.0]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_112]

My /etc/openhab2/services/mqtt.cfg looks as follows:

watsoniot.url=tcp://myorgid.messaging.internetofthings.ibmcloud.com:1883
watsoniot.clientId=g:myorgid:rpi3:Gateway
watsoniot.user=use-token-auth
watsoniot.pwd=######

I already deleted the /var/lib/openhab2/config/org/openhab/mqtt.config as sugested in this thread and it got rebuilt showing the same values as the mqtt.cfg file, yet with double quotes (" ") around them, eg:
watsoniot.url=“tcp://myorgid.messaging.internetofthings.ibmcloud.com:1883”

There are no other brokers listed in this file either.

Again, I am fairly (if not 100%) certain that the credentials are ok, as the stand-alone client successfully connects and Watson also sees it come online. OH2 however will not connect.

What am I missing? How can I further debug this within OH2?

Many thanks for any pointers!
Ronald

I do not believe that OH MQTT supports encrypted TLS connections. If Watson’s broker is configured to encrypt the message traffic using SSL/TLS, I don’t think you can connect to it.

The error is showing that OH can see the broker and it attempts to connect. If you are certain the credentials are correct this is the main thing I can think of that could cause a Not authorized to connect error.

Thanks for responding, Rich. I have not configured Watson to use SSL/TLS, and neither am I specifying it in MQTTBox on my Mac. MQTTBox does connect to Watson, OH2 does not


I do not know this Watson service but it seems to me that if you are not encrypting the traffic you potentially expose your username / password to everybody on the internet.
In any case I would try to use tcpdump to see what is going on during the communication and compare it with another tcpdump capture from the successful communication using MQTTBox. By compating the authentication requests I am sure you will see differences that can point you to the right direction

This seems very confusing and not user friendly. Is there a MQTT binding for OpenHab2 on the way?

It depends on what you want to achieve: I’m using MQTT with mosquitto since openHAB1 without any problems and also the 1.x MQTT binding works flawlessly with openHAB2 


You saved my life. I was going crazy. Thanks a lot Angelos.

1 Like

This helped me as well. the two config files were not allowing the MQTT to work. Thank you.

1 Like

I can not get the mqtt binding to work:

2017-09-10 18:53:38.387 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-09-10 18:53:38.409 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'
2017-09-10 18:53:38.569 [INFO ] [ulation.internal.HueEmulationServlet] - Started Hue Emulation service at /api
2017-09-10 18:53:38.671 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
Unable to connect to server (32103) - java.net.ConnectException: Connection refused (Connection refused)
	at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:75)[221:org.openhab.io.transport.mqtt:1.9.0]
	at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:538)[221:org.openhab.io.transport.mqtt:1.9.0]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)[:1.8.0_121]
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)[:1.8.0_121]
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)[:1.8.0_121]
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)[:1.8.0_121]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)[:1.8.0_121]
	at java.net.Socket.connect(Socket.java:589)[:1.8.0_121]
	at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:66)[221:org.openhab.io.transport.mqtt:1.9.0]
	... 2 more

when I use the karaf console as suggested here this is what is listed out:

openhab> config:edit org.openhab.mqtt
openhab> config:property-list
   mosquitto.async = false
   mosquitto.pwd = xxxxxxx
   mosquitto.qos = 1
   mosquitto.retain = true
   mosquitto.url = tcp://localhost:8883
   mosquitto.user = openhabian
   service.pid = org.openhab.mqtt
openhab>

I did have two mqtt files, so I did:
config:delete org.openhab.mqtt2
bundle:restart 220

any ideas what the problem might be?