Simon Zambrovski
Simon Zambrovski

Reputation: 756

MQTT Mosquitto in bridge mode fails to deliver messages between Raspberry and Cloud

I'm trying to connect two Mqtt Broker (Mosquitto). I installed one on a server in a cloud and another one on a local Raspberry Pi. Raspeberry Pi Mosquitto should establish connection to a cloud instance. This is my configuration on Raspberry (/etc/mosquitto/conf.d/bridge.conf):

connection crowdomat-cloud
address <myserver-hostname>
clientid crowdomat
start_type automatic
cleansession false
notifications true

#
# Send all messages from local /sensor topic to remote /sensor topic
#
topic # both 0 sensor/ sensor/

I can connect to both broker directy and send and receive messages. I also see that connection is established in the log file, but no messages are delivered between the brokers.

1411577927: mosquitto version 1.3.4 (build date 2014-08-22 06:10:51+0000) starting
1411577927: Config loaded from /etc/mosquitto/mosquitto.conf.
1411577927: Opening ipv4 listen socket on port 1883.
1411577927: Opening ipv6 listen socket on port 1883.
1411577927: Warning: Address family not supported by protocol
1411577927: Bridge crowdomat doing local SUBSCRIBE on topic sensor/#
1411577927: Connecting bridge crowdomat-server (my-server:1883)
1411577927: Bridge crowdomat sending CONNECT
1411577927: Received CONNACK on connection crowdomat.
1411577927: Bridge crowdomat sending SUBSCRIBE (Mid: 466, Topic: sensor/#, QoS: 0)
1411577927: Received PUBACK from crowdomat (Mid: 465)
1411577927: Received SUBACK from crowdomat
1411577986: Sending PINGREQ to crowdomat
1411577986: Received PINGRESP from crowdomat
1411578046: Sending PINGREQ to crowdomat
1411578046: Received PINGRESP from crowdomat
1411578069: Received PUBLISH from crowdomat (d0, q0, r0, m0, '/sensor/data', ... (14 bytes))
1411578106: Sending PINGREQ to crowdomat
1411578106: Received PINGRESP from crowdomat
1411578166: Sending PINGREQ to crowdomat
1411578166: Received PINGRESP from crowdomat
1411578193: mosquitto version 1.3.4 terminating
1411578193: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.

Any ideas?

Another mystery is, that I can see the log output only after I shotdown the mosquitto process on Raspberry Pi.

In addition the messages created by Mqtt Lens:

enter image description here enter image description here

Upvotes: 1

Views: 2944

Answers (2)

Saša Pešić
Saša Pešić

Reputation: 61

Something that i figured out by bridging different devices to the Google CLoud Virtual Machine is that you need to set up a protocol version parameter in your devices(local) configuration files.

So, add the bridge_protocol_version version to your mosquitto.conf file on your RPi like this for the bridge connection connecting to the cloud (This one worked for me):

bridge_protocol_version mqttv311

You can also force your configuration file on mosquttio on start like this:

mosquitto -c /etc/mosquitto/conf.d/mosquitto.conf

with mosquitto.conf being the valid configuration file. 

If you have any questions write, i have done a lot with mosquitto and mqtt.

Upvotes: 1

ralight
ralight

Reputation: 11628

I missed this in your question before.

Your bridge is subscribing to sensor/# but you are publishing to /sensor/data. These topics don't match each other. There is a zero length hierarchy string before the first slash of /sensor/data, so that topic is three elements deep: '', 'sensor', 'data'. '' doesn't match the 'sensor' part of your subscription, so no messages are sent.

Long story short, remove the leading slash from /sensor/data and it should work fine.

Upvotes: 1

Related Questions