MQTT Connection not working correctly

After reboot always:

2018-09-12 20:04:39.154 [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) [209:org.openhab.io.transport.mqtt:1.12.0]

at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) [209:org.openhab.io.transport.mqtt:1.12.0]

at java.lang.Thread.run(Thread.java:748) [?:?]

Caused by: java.net.ConnectException: Connection refused (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

So i’m starting it with “mosquitto -d”, is this correct?
Mosquitto is installed through openhabian-config

Yes, make your settings in mqtt-eventbus.cfg which should have been created after installing the binding.

“# Name of the broker as it is defined in the openhab.cfg. If this property is n$
broker=broker”

Was already set (done a time ago)

You need to set that option to the same broker name as in your mqtt binding.

1 Like

mqtt-eventbus.cfg:

broker=mosquitto
commandPublishTopic=/in/${item}
statePublishTopic=/state/${item}
stateSubscribeTopic=/out/${item}
commandSubscribeTopic=/command/${item}/state

or whatever topic you prefer.

mqtt.cfg:

mosquitto.url=tcp://localhost:1883

I think i have to use “broker” instead of mosquitto,

Thats what he was telling you.

BTW why do you need the mqtt ACTION binding for turning on and off a switch? I dont use that binding and have nearly a dozen esp’s working with OH via mqtt.

I may be wrong but I think the question was ask to see if you had it installed, if so then, uninstall it. The action binding has (or had?) a history of interfering with the mqtt binding. So unless you need it, uninstall both mqtt bindings, clean your cache and reinstall the mqtt binding only.

1 Like

Thank you.
I think I’m going to reinstall Openhabian.
I’m writing if it helped.