Bridging Mosquitto to EMQ X Cluster

Scene description

Configure Mosquitto server

  • the address and port of the remote EMQ X server;
  • MQTT protocol parameters, such as protocol version, keepalive, clean_session, etc. (if not configured, the default value is used);
  • Client login information required by EMQ X;
  • the topic of the message that needs to be bridged;
  • Configure bridging topic mapping (no mapping by default).

A simple configuration example

connection emqx1
address 192.168.1.100:1883
bridge_protocol_version mqttv311
remote_username user
remote_password passwd
  • The topic mode specifies the topics that need to be bridged, supporting wildcards;
  • The direction can be in, out or both
  • QoS is the QoS level of the bridge. If not specified, the original QoS of the forwarded message is used.
  • Local and remote prefixes are used for topic mapping, with prefixes on the topic of the forwarded and received messages so that the application can identify the source of the message.
topic sensor/# out 1
topic control/# in 1

Configuring the EMQ X server

Test configuration

Test the out direction of the bridge

$ mosquitto_sub -t "sensor/#" -p 1883 -d -q 1 -h 192.168.1.100

Client mosqsub|19324-Zeus- sending CONNECT
Client mosqsub|19324-Zeus- received CONNACK
Client mosqsub|19324-Zeus- sending SUBSCRIBE (Mid: 1, Topic: sensor/#, QoS: 1)
Client mosqsub|19324-Zeus- received SUBACK
Subscribed (mid: 1): 1
mosquitto_pub -t "sensor/1/temperature" -m "37.5" -d -h 192.168.1.101 -q 1
Client mosqpub|19325-Zeus- sending CONNECT
Client mosqpub|19325-Zeus- received CONNACK
Client mosqpub|19325-Zeus- sending PUBLISH (d0, q1, r0, m1, 'sensor/1/temperature', ... (4 bytes))
Client mosqpub|19325-Zeus- received PUBACK (Mid: 1)
Client mosqpub|19325-Zeus- sending DISCONNECT
Client mosqsub|19324-Zeus- received PUBLISH (d0, q1, r0, m1, 'sensor/1/temperature', ... (4 bytes))
Client mosqsub|19324-Zeus- sending PUBACK (Mid: 1)
37.5

Test the in direction of the bridge

$ mosquitto_sub -t "control/#" -p 1883 -d -q 1 -h 192.168.1.101
Client mosqsub|19338-Zeus- sending CONNECT
Client mosqsub|19338-Zeus- received CONNACK
Client mosqsub|19338-Zeus- sending SUBSCRIBE (Mid: 1, Topic: control/#, QoS: 1)
Client mosqsub|19338-Zeus- received SUBACK
Subscribed (mid: 1): 1
$ mosquitto_pub -t "control/1" -m "list_all" -d -h 192.168.1.100 -q 1
Client mosqpub|19343-Zeus- sending CONNECT
Client mosqpub|19343-Zeus- received CONNACK
Client mosqpub|19343-Zeus- sending PUBLISH (d0, q1, r0, m1, 'control/1', ... (8 bytes))
Client mosqpub|19343-Zeus- received PUBACK (Mid: 1)
Client mosqpub|19343-Zeus- sending DISCONNECT
Client mosqsub|19338-Zeus- received PUBLISH (d0, q1, r0, m2, 'control/1', ... (8 bytes))
Client mosqsub|19338-Zeus- sending PUBACK (Mid: 2)
list_all

--

--

--

EMQ is an open-source IoT data infrastructure software provider, delivering the world’s leading open-source MQTT message broker and stream processing database.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

UnboundLocalError: Local variable referenced before assignment in Python

In this part, I will prepare the project based on the kit’s demo, by duplicates init scene which…

a column must appear in the GROUP BY clause or be used in an aggregate function, When I don't to…

How to setup heroku autoscaling in under 15 minutes?

Difference between Test Scenario and Test Case

What have I learned from migrating and refactoring code ?

Alvin’s Dew Drop Daily — Issue #104

AWS CSA Task2: AWS CLI

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
EMQ Technologies

EMQ Technologies

EMQ is an open-source IoT data infrastructure software provider, delivering the world’s leading open-source MQTT message broker and stream processing database.

More from Medium

Enabling SSL on PostgreSQL

Handle multiple databases in bitbucket Pipelines

Apache Tomcat with Nginx Proxy on Ubuntu 20.04

Install PostgreSQL on MacOS