After stretching for numerous hours and scratching my head in solving MQTT binding issue in Openhab2, I have decided to write in this forum to seek help.
My Scenario :
I am not able to bind MQTT into openhab2 . I tried installing and uninstalling MQTT Binding(binding-mqtt1 - 1.12.0.RC2) using PaperUI -> Addons multiple times but not sure why it is not reflecting in Configuration-> Bindings screen.I also tried deleting /org/openhab/mqtt.config few times but no change in the outcome.
Here are the log file details. openhab2/openhab.log
018-05-30 01:39:13.292 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-05-30 01:39:13.487 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-05-30 01:39:13.585 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-05-30 01:39:13.941 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-05-30 01:39:13.952 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection āā
2018-05-30 01:39:14.196 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttException: Unable to connect to server
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:79) [217:org.openhab.io.transport.mqtt:1.12.0.RC2]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) [217:org.openhab.io.transport.mqtt:1.12.0.RC2]
at java.lang.Thread.run(Thread.java:745) [?:?]
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:?]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:?]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:?]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]
at java.net.Socket.connect(Socket.java:589) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:70) ~[?:?]
services/mqtt.cfg ( for obvious reason i have masked the IP address,User & Pwd_
ābroker.url=tcp://192.XX.XX.XX:1883ā
broker.clientId=openhab2
broker.user=XXXX
broker.pwd=XXXX
note : bracket is included in the original syntaxā¦
I am still not able to bind the MQTT to Addons. Please find the Openhab (var/log/openhab2/openhab.log) and Mosquitto log file below.
Appreciate your help.
2018-05-30 23:41:11.387 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) se$
2018-05-30 23:41:12.597 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model āMyHome.thingsā
2018-05-30 23:41:14.801 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-05-30 23:41:14.933 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-05-30 23:41:15.074 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-05-30 23:41:15.386 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-05-30 23:41:15.405 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection āā
2018-05-30 23:41:15.705 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttException: Unable to connect to server
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:79) [219:org.openh$
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) [219:org.openha$
at java.lang.Thread.run(Thread.java:745) [?:?]
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:?]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:?]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:?]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]
at java.net.Socket.connect(Socket.java:589) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:70) ~[?:?]
ā¦ 2 more
2018-05-30 23:41:15.767 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ābrokerā
2018-05-30 23:41:15.802 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttException: Unable to connect to server
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:79) [219:org.openh$
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) [219:org.openha$
at java.lang.Thread.run(Thread.java:745) [?:?]
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:?]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:?]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:?]
here is Mosquitto log file
1527339623: Config loaded from /etc/mosquitto/mosquitto.conf.
1527339623: Opening ipv4 listen socket on port 1883.
1527339623: Opening ipv6 listen socket on port 1883.
1527339623: Opening ipv4 listen socket on port 1883.
1527339623: Error: Address already in use
As you suggested I made the changes to mosquitto.conf and mqtt.cfg file however I am still not able to see MQTT binding under configuration.
Here are the log files.
Openhab.log
2018-05-31 20:53:03.152 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection āā
2018-05-31 20:53:13.476 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
org.eclipse.paho.client.mqttv3.MqttException: Connection lost
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146) [223:org.openhab.io.transport.mqtt:1.12.0.RC2]
at java.lang.Thread.run(Thread.java:745) [?:?]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107) ~[?:?]
ā¦ 1 more
2018-05-31 20:53:13.500 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to āā was lost: Connection lost : ReasonCode 32109 : Cause : null
2018-05-31 20:53:13.502 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker āā
Mosquitto.log
527339623: mosquitto version 1.5 starting
1527339623: Config loaded from /etc/mosquitto/mosquitto.conf.
1527339623: Opening ipv4 listen socket on port 1883.
1527339623: Opening ipv6 listen socket on port 1883.
1527339623: Opening ipv4 listen socket on port 1883.
1527339623: Error: Address already in use
Moreover , I am getting a peculiar socket error when I run pi@raspberry:~$mosquitto .Not sure if it is related to the actual issue.
1527825741: New connection from 192.XXX.X.XX on port 1883.
1527825741: Client openhab2 already connected, closing old connection.
1527825741: Socket error on client openhab2, disconnecting.
1527825741: New client connected from 192.XXX.X.XX as openhab2 (c1, k60, uāusernameā).
After step 3 when I went back to /var/lib/openhab2/config/org/openhab/mqtt.config
but it is still showing me
.clientId=āopenhab2ā
.pwd=āHomeHubā
.url=ātcp://192.168.X.XX:1883ā
.user=āusernameā
service.pid=āorg.openhab.mqttā
however , /etc/openhab2/services/mqtt.cfg has different sequence of lineā¦
pid:org.openhab.mqtt
.url=tcp://192.168.XX.XX:1883
.clientId=openhab2
.user=username
.pwd=HomeHub
do you think /var/lib/openhab2/config/org/openhab/mqtt.config is pulling the configuration from old instance? If yes how to delete itā¦? Is there anything we can do from Openhab console to delete the old configurationā¦
check folder /etc/openhab2/services/ for extra cfg files which contain mqtt configsā¦
make sure that you are using the correct fileā¦ maybe thatās why the pid: line didnāt workā¦
Use Code fencesā¦ I am not sure that you are posting correctly the file contents (and by the way: your IP is RFC1918 so nothing to worry about :))