Is the broker running at the mqttbroker configuration settings in openhab.cfg? Can you use mosquitto_sub at a command line to attempt to connect the same way?
# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
mqtt:MQTTbroker.url=tcp://192.168.0.9:1883
# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a default one is generated.
mqtt:MQTTbroker.clientId=openHAB
I get data when i use: mosquitto_sub -h 192.168.0.9 -t /#
I have a different problem after upgrading from 1.7 to 1.8: all my contacts items stopped working. I realized the Contact items using the MQTT binding would not accept the “command” type anymore.
So Contact myContactItem {mqtt="<[myBroker:/topic/sub_topic:command:default]} does not work in 1.8 (it was working in 1.7). But Contact myContactItem {mqtt="<[myBroker:/topic/sub_topic:state:default]} still works…
Note the problem only happens with Contact items (default = OPEN / CLOSED) while Switch items (default = ON / OFF) still work OK.
I am pretty sure it’s a result of my code change, but I believe it was incorrect to be able to send commands to Contact items in the first place. The code for Contact items does not accept any command to be sent to them, but the reason it probably worked was a side effect of the previous code that ended up changing their state due to auto-update logic. (To test my theory, the items would probably not update if you use the Contact items under the 1.7.* MQTT binding but add , autoupdate="false" to the { binding section }.)
The reason it works with Switch items is because it is permitted (obviously) to send Switches commands, as the Switch item code shows.
The better approach is to change your MQTT binding strings for updating Contact items to update their state, not send them commands, so it conforms to the rules for item commands and states.