[英]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.