Need help to setup MQTT Binding on OH2

Good Morning Vincent !

No, it did not work. Here is the OH log…

2018-06-01 08:46:44.929 [WARN ] [g.dispatch.internal.ConfigDispatcher] - The file /etc/openhab2/services/mqtt.cfg subsequently defines the exclusive PID 'org.$
2018-06-01 08:46:44.942 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-06-01 08:46:44.945 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
2018-06-01 08:46:44.980 [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) [225:org.openhab.io.transport.mqtt:1.12.0.RC2]
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) [225: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) ~[?:?]
        ... 2 more

reboot the pi

it seems that mosquitto is not running (it doesn’t seem to be an auth issue)
it is strange but if you don’t put anything (port, listener, etc) in the config file for networking… it works (it uses the defaults) :stuck_out_tongue:
(I saw this recently on my rPi3 after I upgraded mosquitto to v1.5)

try the following for mosquitto.conf:

persistence false
log_dest file /var/log/mosquitto/mosquitto.log
log_type information
connection_message true
log_timestamp true
allow_anonymous false
password_file /etc/mosquitto/pwfile

@Vincent

I did reboot pi. Here is OH log

2018-06-01 08:57:55.755 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-06-01 08:57:56.953 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'MyHome.things'
2018-06-01 08:57:58.897 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-06-01 08:57:59.058 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-06-01 08:57:59.136 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-06-01 08:57:59.544 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-06-01 08:57:59.551 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
2018-06-01 08:57:59.826 [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) [225:org.openhab.io.transport.mqtt:1.12.0.RC2]
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) [225: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) ~[?:?]

fix your mosquitto

uninstall and purge mosquitto

sudo apt-get purge mosquitto
sudo reboot

Then follow:

STEP BY STEP
Don’t skip one thinking that you know better. You don’t

Sure !

Let me uninstall and purge mosquitto.

if you don’t fix your mosquitto.conf… you will spend all week here :slight_smile:
comment out all networking options from the file and check if mosquitto is running
then, OH2 will connect (your mqtt.cfg is finally correct)

sure !

Just another input for your guys while I am trying to install Mosquitto again… I had MQTT.fx runnning on another PC and till yesterday it was connecting properly with MQTT broker… In fact I was able to publish and subscribe messages…

now… MQTT.fx cannot connect to the broker… correct?

Yes

mosquitto ist kaput!! the mosquitto is dead, we don’t really know what you have been trying to do to get it back up and running so I think it’s better that you start from scracth and remove it and re-install it

@Dim, what do you think?

1 Like

yes , that what i am doing now… I have purged mosquitto… and following the steps you mentioned in previous thread…

There is an open issue with Eclipse with regards to Mosquitto v1.5 on Debian Jessie (most likely this is what Rajeev) is running

If you specify any networking options in the config file: It launches the default plus whatever you defined in your mosquitto.conf… causing a conflict and you get:

Error: Address already in use

Some people say that this can be fixed if you upgrade Jessie to Stretch which will update libwebsockets.so
There is no root-cause identified yet and no definite solution…

more info on:

  1. Mosquitto stopped working after upgrade to v 1.5
  2. https://github.com/eclipse/mosquitto/issues/825
  3. https://github.com/eclipse/mosquitto/issues/837#issuecomment-392607455
1 Like

quick question:

I am using below source to download mosquitto. Do you have any other recommendation?

wget https://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list 
sudo -i
sudo apt-get install mosquitto
sudo apt-get install mosquitto-clients
sudo apt-get update

Use the raspberry pi source
You don’t need:

wget https://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list

If you did that before you need to remove the repo from the repo list.
Sorry I got ahead of myself

The raspberry pi repository has mosquitto in it
Use that one as it is GUARANTEED to work with your pi

Who told you to install another repository for your rasperry pi is a twit.

Just do:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mosquitto
1 Like

btw: @rajeev2301 is your Raspbian based on Debian Jessie (8) or Stretch (9)?

output of

lsb_release -a
pi@raspberrypi:~ $ lsb_release -a

|Distributor ID:|Raspbian|
|---|---|
|Description:|Raspbian GNU/Linux 9.4 (stretch)|
|Release:|9.4|
|Codename:|stretch|

sudo apt-get purge mosquitto
sudo reboot
...
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mosquitto
1 Like

I have reinstalled mosquitto

here is the log OH file and mosquitto log file.

2018-06-01 11:44:32.943 [INFO ] [er.internal.HomeBuilderDashboardTile] - Started Home Builder at /homebuilder
2018-06-01 11:44:34.546 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.XX.X.XX:8080
2018-06-01 11:44:34.550 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.XX.X.XX:8443
2018-06-01 11:45:09.155 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'Myhome.items' has errors, therefore i$

2018-06-01 11:45:13.705 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-06-01 11:45:14.899 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'MyHome.things'
2018-06-01 11:45:17.121 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-06-01 11:45:17.311 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-06-01 11:45:17.516 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-06-01 11:45:17.523 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
2018-06-01 11:45:17.683 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-06-01 11:45:17.758 [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) [205:org.openhab.io.transport.m$
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) [205:org.openhab.io.transport.mq$
        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) ~[?:?]

Mosquitto log file

1527876354: Opening ipv6 listen socket on port 1883.
1527876424: New connection from 127.0.0.1 on port 1883.
1527876424: New client connected from 127.0.0.1 as paho51879022739 (c1, k60).
1527876760: New connection from ::1 on port 1883.
1527876760: New client connected from ::1 as mosqpub|1865-raspberryp (c1, k60, $
1527876760: Client mosqpub|1865-raspberryp disconnected.
1527876777: New connection from ::1 on port 1883.
1527876777: New client connected from ::1 as mosqsub|1876-raspberryp (c1, k60, $
1527876781: New connection from ::1 on port 1883.
1527876781: New client connected from ::1 as mosqpub|1877-raspberryp (c1, k60, $
1527876781: Client mosqpub|1877-raspberryp disconnected.
1527876809: Socket error on client mosqsub|1876-raspberryp, disconnecting.
1527876809: mosquitto version 1.5 terminating