[英]bridging mqtt brokers hivemq and mosquitto
我正在尝试在同一系统上桥接两个MQTT代理HiveMQ
和Mosquitto
。 HiveMQ
正在1884
端口上运行,而Mosquitto
正在1883
端口上运行。 但是,当我使用mosquitto_pub
命令在端口1883
上发布到mosquitto
代理时,它不会显示在端口1884
(使用MQTT.fx
作为订阅端口1884
上所有主题的客户端)
这是我只为mosquitto
经纪人配置了网桥的时候。 当我同时配置HiveMQ
,它仅在HiveMQ
命令窗口上显示unable to connect to Bridge1, disconnected
HiveMQ
unable to connect to Bridge1, disconnected
消息。 我已包含以下配置。 有人请帮忙。
在mosquitto.config
文件中,我在bridges
下进行了以下操作。
connection hivemq
address 127.0.0.1:1884
start_type automatic
clientid clientno1
notifications true
同时,我还编辑了HiveMQ bridges.xml
文件以读取
<?xml version="1.0" encoding="UTF-8"?>
<bridges xsi:noNamespaceSchemaLocation="http://www.hivemq.com/bridges/bridge.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<bridge>
<connectionName>Bridge1</connectionName>
<addresses>
<address>
<host>localhost</host>
<port>1883</port>
</address>
</addresses>
<clientId>bridgeClient</clientId>
<topicPatterns>
<topicPattern>
<topic>#</topic>
<qos>1</qos>
<direction>both</direction>
<localPrefix>local/</localPrefix>
<remotePrefix>remote/</remotePrefix>
</topicPattern>
</topicPatterns>
<cleanSession>true</cleanSession>
<idleTimeout>10</idleTimeout>
<notificationsEnabled>true</notificationsEnabled>
<tryPrivate>true</tryPrivate>
</bridge>
所示图像是在另一个系统上尝试相同过程时的图像。 在这里,经纪人是桥梁。 与我之前所做的比较,唯一的区别是在我的原始系统上没有声明说在1883年打开ipv4 listen socket。这是问题吗?
您只需要在其中一个代理中配置桥,为这两个代理配置桥将导致问题,最可能是消息循环
对于您的mosquitto配置,您需要在mosquitto桥上添加一个主题行,以便它知道要发送(和接收)到配置单元代理的主题
可以在mosquitto.conf手册页( http://mosquitto.org/man/mosquitto-conf-5.html )中找到有关topic指令的完整详细信息,但基础知识是:
主题模式[[[out | 在| 两者[qos级]本地前缀[远程前缀]
双向镜像所有主题
topic # both
桥接只能在发布者/客户端(在您的情况下为mosquitto)上进行设置,而在Hivemq(服务器)上保留默认设置应该可以
尝试更改您的mosquitto.conf
connection bridge-mosquitto-to-hivemq
address 127.0.0.1:1884
topic room1/# both 2 sensor/ myhouse/
bridge_protocol_version mqttv311
notifications true
cleansession true
try_private true
重新启动代理后,在mosquitto代理处,尝试在下面发布示例消息
mosquitto_pub -t sensor/room1/temperature -m '26.3'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.