Mqtt not working

Hello,

i’m having trouble to get mqtt working within openhab.
Today i downloaded and installed openhabian on a raspberry pi 2.
after installing i ssh into te pi to install through the config util mqtt.

mqtt is running, i checked it with mqtt-spy, from command line on the pi i can send a mqtt update.
this is displayd in mqtt-spy.

when i look at the log file of openhab, there is one error involving mqtt.
what is causing this problem and how to solve this.

2018-01-04 14:54:53.144 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mqtt'
2018-01-04 14:54:53.381 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
java.lang.IllegalArgumentException: tcp://127.0.0.1:1883/
	at org.eclipse.paho.client.mqttv3.MqttConnectOptions.validateURI(MqttConnectOptions.java:497) [208:org.openhab.io.transport.mqtt:1.11.0]
	at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:291) [208:org.openhab.io.transport.mqtt:1.11.0]
	at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:185) [208:org.openhab.io.transport.mqtt:1.11.0]
	at org.eclipse.paho.client.mqttv3.MqttClient.<init>(MqttClient.java:226) [208:org.openhab.io.transport.mqtt:1.11.0]
	at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.openConnection(MqttBrokerConnection.java:295) [208:org.openhab.io.transport.mqtt:1.11.0]
	at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.start(MqttBrokerConnection.java:99) [208:org.openhab.io.transport.mqtt:1.11.0]
	at org.openhab.io.transport.mqtt.MqttService.updated(MqttService.java:115) [208:org.openhab.io.transport.mqtt:1.11.0]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1479) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1435) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109) [7:org.apache.felix.configadmin:1.8.16]
	at java.lang.Thread.run(Thread.java:748) [?:?]

below is mij mqtt.cfg

mqtt:mqtt.url=tcp://192.168.1.19:1883
mqtt:mqtt.clientId=piq
mqtt:mqtt.qos=0
mqtt:mqtt.async=false
mqtt:mqtt.retain=false

My mqtt-eventbus.cfg is empty.

after deinstalling en installing the binding i get a different error.

018-01-04 16:21:29.141 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'piq' was lost: Connection lost : ReasonCode 32109 : Cause : null
2018-01-04 16:21:29.146 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'piq'

still going on with my search.

stop OH2
fix your /etc/openhab2/services/mqtt.cfg

use_another_broker_name_here.url=tcp://192.168.1.19:1883
use_another_broker_name_here.clientId=openhab2system
use_another_broker_name_here.qos=0
use_another_broker_name_here.async=true
use_another_broker_name_here.retain=false

delete file /var/lib/openhab2/config/org/openhab/mqtt.config

start OH2 & monitor logs

thanks,

it looks like it is started.
but not sending data if i hit an item

below a part of my items.

Switch MQTTLED "Test" (all) {mqtt=">[MQTT:subwoofer/gpio/12:command:ON:1],>[MQTT:/Subwoofer/gpio/2:command:OFF:0]"}

and my sitemap

sitemap default label="My first sitemap"
{
	Frame label="MQTT Test"{
 		Switch item=MQTTLED label="LED"
	}


}

do i need to put somthing in mqtt-eventbus.cfg

post your mqtt.cfg file
what is the name of your broker?

the name of the broker is ajg.

ajg.url=tcp://192.168.1.19:1883
ajg.clientId=openhab2system
ajg.qos=0
ajg.async=true
ajg.retain=false

do i have to change MQTT in ajg ?
sorry for all this maybe stupid questions, it’s my first time with openhab an mqtt.
i’m in the transit of domoticz to openhab :slight_smile:

yup :slight_smile:

do i also need to restart openhab after changing.
but it didn’t help

Still nothing is sending to the broker !
what else could be wrong

here are my config files.

mqtt.cfg

ajg.url=tcp://192.168.1.19:1883
ajg.clientId=openhab2system
ajg.qos=0
ajg.async=true
ajg.retain=false

mqtt-eventbus.cfg

# Name of the broker as it is defined in the openhab.cfg. If this property is not available, no event bus MQTT binding will be created.
#broker=ajg

# When available, all status updates which occur on the openHAB event bus are published to the provided topic. The message content will 
# be the status. The variable ${item} will be replaced during publishing with the item name for which the state was received.
#statePublishTopic=/openHAB/OUT/${item}/state

# When available, all commands which occur on the openHAB event bus are published to the provided topic. The message content will be the 
# command. The variable ${item} will be replaced during publishing with the item name for which the command was received.
#commandPublishTopic=/openHAB/OUT/${item}/command

# When available, all status updates received on this topic will be posted to the openHAB event bus. The message content is assumed to be 
# a string representation of the status. The topic should include the variable ${item} to indicate which part of the topic contains the 
# item name which can be used for posting the received value to the event bus.
#stateSubscribeTopic=/openHAB/in/${item}/state

# When available, all commands received on this topic will be posted to the openHAB event bus. The message content is assumed to be a 
# string representation of the command. The topic should include the variable ${item} to indicate which part of the topic contains the 
# item name which can be used for posting the received value to the event bus.
#commandSubscribeTopic=/openHAB/in/${item}/command

default.items

Switch MQTTLED "Test" (all) {ajg=">[ajg:subwoofer/gpio/12:command:ON:1],>[ajg:/Subwoofer/gpio/2:command:OFF:0]"}

default.sitemap

sitemap default label="My first sitemap"
{


	Frame label="MQTT Test"{
 		Switch item=MQTTLED label="LED"
	}


}

and the log from openhab.log

2018-01-04 17:55:16.081 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'default.sitemap'
2018-01-04 17:55:26.269 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-01-04 17:55:26.529 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-01-04 17:55:26.914 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-01-04 17:55:27.310 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin
2018-01-04 17:55:28.721 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-01-04 17:55:28.733 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'ajg'

sorry, had somthing wrong in spy-mqtt, it seems all working fine :slight_smile