MQTT Problems no messages received

Hello there, I have a strange problem here. Maybe i just have some configuration problems or what I try to do just doesn’t work this way…

I have a raspberry pi with mosquitto installed. I can send and receive Messages (tested locally with mosquitto sub/pub and my cellphone). Now I wanted to start integration in OH.

What I want to do is to display the text of a MQTT message in a String:

String mqtttest "[%s]" {mqtt="<[mqtt1:/openhabmqtt:state:default]"}

It just displays “-”

Thank You!

If OH1.8.3: did you install the MQTT binding in addons/org.openhab.persistence.mqtt-1.8.3.jar?

Hi… no sorry, still using 1.7.x thought persistence addon wouldn’t be neccesary?

This means that item has yet to receive any message.

I highly recommend moving to 1.8.3 or 2.0 at some point in the very near future. There has been so many updates, upgrades, and changes since that version that it will be impossible for us to tell whether your current problem is one of configuration or a known bug that has already been fixed.

It isn’t, I think @Max_G misspoke and meant the org.openhab.binding.mqtt-1.7.jar file.

What is your MQTT config in openhab.cfg?

Do you see anything in the logs, particularly do you see a message saying MQTT is connecting or any errors from MQTT?

Sorry, I didi copy the wrong file name… :frowning:

Meine Konfiguration sieht in der openhab.cfg so aus:

mqtt:mqtt1.url=tcp://xxx.xxx.xxx.xxx:yyyy                                                                                                                                                     
mqtt:mqtt1.user=username                                                                                                                                                                   
mqtt:mqtt1.pwd=password                                                                                                                                                                       
mqtt:mqtt1.qos=2                                                                                                                                                                              
mqtt:mqtt1.retain=true                                                                                                                                                                        
mqtt:mqtt1.async=true                                                                                                                                                                         
mqtt:mqtt1.clientId=OpenHABMQTT 

In der default.items habe ich folgende Zeile:

String mqtttest "[%s]" {mqtt="<[mqtt1:/openhabmqtt:state:default]"}

In der default.sitemap habe ich:

Text item=mqtttest  

Openhab läuft auf Version 1.8.3 (Habs hochgezogen hat aber keine Änderung gebracht)

Folgende mqtt bezogene Pakete habe ich installiert:

openhab-addon-action-mqtt (seit gestern abend aber erst)
openhab-addon-binding-mqtt
openhab-addon-binding-mqttitude

Die openhab.log zeigt mir:

[INFO ] [.io.transport.mqtt.MqttService] - MQTT Service initialization completed.                                                                                     
[INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting MQTT broker connection 'mqtt1'  
[ERROR] [o.i.t.m.i.MqttBrokerConnection] - MQTT connection to broker was lost  

org.eclipse.paho.client.mqttv3.MqttException: Verbindung wurde getrennt                                                                                                                       
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138) [mqtt-client-0.4.0.jar:na]                                                                       
        at java.lang.Thread.run(Thread.java:745) [na:1.7.0_60]                                                                                                                                
Caused by: java.io.EOFException: null                                                                                                                                                         
        at java.io.DataInputStream.readByte(DataInputStream.java:267) ~[na:1.7.0_60]                                                                                                          
        at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56) ~[na:na]                                                                 
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100) [mqtt-client-0.4.0.jar:na]                                                                       
        ... 1 common frames omitted     

 MQTT connection to 'mqtt' was lost: Verbindung wurde getrennt : ReasonCode 32109 : Cause : null                            
[INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'mqtt'                                         
[INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting MQTT broker connection 'mqtt1'                                                                                     
[ERROR] [o.i.t.m.i.MqttBrokerConnection] - MQTT connection to broker was lost                                                                                         
org.eclipse.paho.client.mqttv3.MqttException: Verbindung wurde getrennt                                                                                                                       
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138) [mqtt-client-0.4.0.jar:na]                                                                       
        at java.lang.Thread.run(Thread.java:745) [na:1.7.0_60]                                                                                                                                
Caused by: java.io.EOFException: null                                                                                                                                                         
        at java.io.DataInputStream.readByte(DataInputStream.java:267) ~[na:1.7.0_60]                                                                                                          
        at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56) ~[na:na]                                                                 
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100) [mqtt-client-0.4.0.jar:na]                                                                       
        ... 1 common frames omitted                                                                      

In der events.log findet sich kein Eintrag, dass das item mqtttest jemals ein update erfahren hätte.
Die Fehlermeldungen im Openhab.log tauchen erst auf, seit ich das mqtt-action paket installiert habe.

 service mosquitto status
● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto)                                                                                                                                                     
   Active: active (running) since Do 2016-12-08 08:51:14 CET; 22h ago
   CGroup: /system.slice/mosquitto.service                                                                                                                                                    
           └─398 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf    

I don’t speak German so can only comment based on the configurations.

The log is an indication that the binding is either failing to connect to the broker or the connection is being refused. The timestamps are missing so I can’t tell how far apart the connect and failure are.

Do you see anything in mosquitto’s log that might indicate why/whether mosquitto is refusing the connection (wrong usrename/password perhaps?)

1 Like