Emqx: About setting MQTT bridge with EMQ

Created on 7 Dec 2017  路  5Comments  路  Source: emqx/emqx

I read about setting-up a bridge between e.g. a Mosquitto broker and EMQ http://emqtt.io/docs/v2/bridge.html#

But, I haven't (SSH) access to the 'source' MQTT broker I want to bridge with EMQ. But I have it's host name and credentials (username and password).
Is it possible to initiate, with this info, the bridging from my EMQ broker (to which I have SSH access + all needed permissions)?

Thanks.

Enhancement

Most helpful comment

You should define two connections (either in mosquitto.conf or in separate files in /etc/mosquitto/conf.d/), one to cloudmqtt in this case, and the other to emq. Then tell mosquitto which topics you would like to forward, and in which direction.

/etc/mosquitto/conf.d/emq.conf

connection emq
address 127.0.0.1:1883
topic livingroom/sensors/# in 0

/etc/mosquitto/conf.d/iot.conf

connection iot
address iot.eclipse.org:1883
topic # out 0 livingroom/sensors/ vic-01234567890/livingroom/sensors

This (semi-fictional) example would subscribe (with QOS 0) to my internal EMQ's on topic livingroom/sensors/#, and forwards _all_ received messages (also with QOS 0) to public broker iot.eclipse.org. At the same time, it slightly changes the topics (it prepends vic-01234567890 as a root to all topics, in order to avoid topic collisions with other people publishing to that public broker).

In your case, it seems to want to import from the public broker, and send to emq. So you would need to swap the _in_ and _out_ lines between the brokers.

There are many tutorials on briding in mosquitto. This one seems all right.

Hope that helps.

All 5 comments

I had the same issue, and I created a workaround by putting a mosquitto instance in between, and bridging mosquitto to both EMQ and the other [public] broker. I don't think you can do this from EMQ directly.

ok thanks for the workaround, if not possible otherwise: a lot of 'bridging' :)

@victorclaessen @gdillen could you be so kind to help me setting up a bridge between a public broker (cloudmqtt) and emq (which is local)? Have managed to setup a mosquitto bridge who connects to cloudmqtt, but how do i forward it to emq (cluster)? An example mosquitto.conf would be very helpful :-)

You should define two connections (either in mosquitto.conf or in separate files in /etc/mosquitto/conf.d/), one to cloudmqtt in this case, and the other to emq. Then tell mosquitto which topics you would like to forward, and in which direction.

/etc/mosquitto/conf.d/emq.conf

connection emq
address 127.0.0.1:1883
topic livingroom/sensors/# in 0

/etc/mosquitto/conf.d/iot.conf

connection iot
address iot.eclipse.org:1883
topic # out 0 livingroom/sensors/ vic-01234567890/livingroom/sensors

This (semi-fictional) example would subscribe (with QOS 0) to my internal EMQ's on topic livingroom/sensors/#, and forwards _all_ received messages (also with QOS 0) to public broker iot.eclipse.org. At the same time, it slightly changes the topics (it prepends vic-01234567890 as a root to all topics, in order to avoid topic collisions with other people publishing to that public broker).

In your case, it seems to want to import from the public broker, and send to emq. So you would need to swap the _in_ and _out_ lines between the brokers.

There are many tutorials on briding in mosquitto. This one seems all right.

Hope that helps.

@victorclaessen Just what I needed! I guess I got confused after hour of reading and trying, but the conf examples and explaination just helps me out and now its working!

Thanks for helping me out 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

franquis picture franquis  路  5Comments

viest picture viest  路  5Comments

codewiget95 picture codewiget95  路  6Comments

mikybone picture mikybone  路  3Comments

arnecs-piscada picture arnecs-piscada  路  5Comments