我试图在同一个系统上连接两个MQTT代理,即HiveMQ和Mosquitto。HiveMQ正在运行1884端口,Mosquitto运行在1883上。但是,当我使用mosquitto_pub命令发布到端口1883的mosquitto broker时,它不会出现在端口1884上(使用MQTT.fx作为客户端订阅端口1884上的所有主题)。
这是我只配置了一个桥的mosquitto代理。当我也配置HiveMQ时,它只在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侦听套接字。这就是问题所在吗?
发布于 2016-06-03 08:22:15
桥接只应设置在发布服务器/客户端(在您的情况下是蚊帐),在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_pub -t sensor/room1/temperature -m '26.3'发布于 2015-06-04 09:21:01
您只需要在其中一个代理中配置桥接器,为两者配置桥接器将导致问题,最有可能的是消息循环。
对于你的蚊子配置,你需要在你的蚊子桥上添加一个主题行,这样它就知道要把什么主题发送(和接收)给蜂巢经纪人。
有关主题指令的详细信息可以在mosquitto.conf手册页(http://mosquitto.org/man/mosquitto-conf-5.html)中找到,但基本内容如下:
主题模式[在两个qos级别]本地前缀远程前缀]
在两个方向镜像所有主题
topic # bothhttps://stackoverflow.com/questions/30639486
复制相似问题