我正在尝试仅使用docker-compose创建EMQ X桥接设置(MQTT桥接)。作为参考,我正在看官方文件。我想到的用例是桥接EMQ X Edge (emqx-edge
)到EMQ X (emqx
),然后当消息发布到emqx-edge
时,它将被转发到emqx
。到目前为止,我已经创建了两个代理和一个网络,因此它们可以通信(poc-bridge)。
问题是:当消息发布到一个主题(e。gsensor1/#
)到emqx-edge
broker,它从未到达emqx
broker。我不知道哪里出错了。
下面是我到目前为止的docker-compose。
version: '3.3'
networks:
poc-bridge:
external: true
services:
mqtt-edge:
image: emqx/emqx-edge:latest
container_name: edge-broker
restart: always
environment:
- EMQX_LOADED_PLUGINS= "emqx_bridge_mqtt"
- EMQX_ADMIN_PASSWORD=brokerpw1
- EMQX_BRIDGE__MQTT__AWS__ADDRESS=172.26.0.2:1883 #ip:port of mqtt-cloud
- EMQX_BRIDGE__MQTT__AWS__PROTO_VER=mqttv3
- EMQX_BRIDGE__MQTT__AWS__BRIDGE_MODE=true
- EMQX_BRIDGE__MQTT__AWS__CLEAN_START=true
- EMQX_BRIDGE__MQTT__AWS__USERNAME=user
- EMQX_BRIDGE__MQTT__AWS__PASSWORD=passw
- EMQX_BRIDGE__MQTT__AWS__CLIENTID=bridge_aws
- EMQX_BRIDGE__MQTT__AWS__KEEPALIVE=10s
- EMQX_BRIDGE__MQTT__AWS__FORWARDS=sensor1/#
networks:
- poc-bridge
ports:
- 18083:18083
- 1883:1883
- 8883:8883
- 8083:8083
depends_on:
- mqtt-cloud
mqtt-cloud:
image: emqx/emqx:latest
container_name: cloud-broker
restart: always
networks:
- poc-bridge
ports:
- 51883:1883
- 58883:8883
- 58083:8083
问题解决。我还漏了一些构型…下面是用于桥接emqx-edge到emqx的docker-compose yaml。
version: '3.3'
networks:
poc-bridge:
external: true
services:
mqtt-edge:
image: emqx/emqx-edge:latest
container_name: edge-broker
restart: always
environment:
- EMQX_LOADED_PLUGINS="emqx_bridge_mqtt,emqx_recon,emqx_retainer,emqx_management,emqx_dashboard"
- EMQX_ADMIN_PASSWORD=brokerpw1
- EMQX_BRIDGE__MQTT__AWS__START_TYPE=auto
- EMQX_BRIDGE__MQTT__AWS__ADDRESS=172.26.0.2:1883 # docker-ip:port of mqtt-cloud
- EMQX_BRIDGE__MQTT__AWS__PROTO_VER=mqttv3
- EMQX_BRIDGE__MQTT__AWS__BRIDGE_MODE=true
- EMQX_BRIDGE__MQTT__AWS__CLEAN_START=true
- EMQX_BRIDGE__MQTT__AWS__USERNAME=user
- EMQX_BRIDGE__MQTT__AWS__PASSWORD=passw
- EMQX_BRIDGE__MQTT__AWS__CLIENTID=bridge_aws
- EMQX_BRIDGE__MQTT__AWS__KEEPALIVE=60s
- EMQX_BRIDGE__MQTT__AWS__FORWARD_MOUNTPOINT=bridge/aws/test/
- EMQX_BRIDGE__MQTT__AWS__FORWARDS=atlas/#
#- EMQX_BRIDGE__MQTT__AWS__SUBSCRIPTION__1__TOPIC=atlas/#
#- EMQX_BRIDGE__MQTT__AWS__SUBSCRIPTION__1__QOS=1
networks:
- poc-bridge
ports:
- 18083:18083
- 1883:1883
- 8883:8883
- 8083:8083
depends_on:
- mqtt-cloud
mqtt-cloud:
image: emqx/emqx:latest
container_name: cloud-broker
restart: always
environment:
- EMQX_LOADED_PLUGINS= "emqx_bridge_mqtt"
networks:
- poc-bridge
ports:
- 51883:1883
- 58883:8883
- 58083:8083