问题
希望使用 mosquitto 的 bridge 功能,将本地 mqtt 服务器的信息转发至 EMQX Cloud 服务器上,但始终提示无法连接。Client local.client_id closed its connection.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| root@OpenWrt:~# mosquitto -c /etc/mosquitto/mosquitto.conf -v
1722342917: mosquitto version 2.0.18 starting
1722342917: Config loaded from /etc/mosquitto/mosquitto.conf.
1722342917: Opening ipv4 listen socket on port 1883.
1722342917: Opening ipv6 listen socket on port 1883.
1722342917: Bridge local.OpenWrt.emqx doing local SUBSCRIBE on topic mytopic
1722342917: Connecting bridge emqx (v6q9efjc.abc.cn-hangzhou.emqxsl.cn:8883)
1722342917: Bridge OpenWrt.emqx sending CONNECT
1722342917: mosquitto version 2.0.18 running
1722342918: Client local.OpenWrt.emqx closed its connection.
1722342924: Bridge local.OpenWrt.emqx doing local SUBSCRIBE on topic mytopic
1722342924: Connecting bridge emqx (v6q9efjc.abc.cn-hangzhou.emqxsl.cn:8883)
1722342924: Bridge OpenWrt.emqx sending CONNECT
1722342924: Client local.OpenWrt.emqx closed its connection.
|
解决办法
多次尝试后,无意中发现将 bridge_protocol_version
的值从默认的 mqttv311
修改为 mqttv50
即可解决。原因不详。
1
2
3
4
| # mosquitto.conf
- bridge_protocol_version mqttv311
+ bridge_protocol_version mqttv50
|
成功连接
1
2
3
4
5
6
7
8
9
10
11
12
13
| root@OpenWrt:~# mosquitto -c /etc/mosquitto/mosquitto.conf -v
1722343382: mosquitto version 2.0.18 starting
1722343382: Config loaded from /etc/mosquitto/mosquitto.conf.
1722343382: Opening ipv4 listen socket on port 1883.
1722343382: Opening ipv6 listen socket on port 1883.
1722343382: Bridge local.OpenWrt.emqx doing local SUBSCRIBE on topic mytopic
1722343382: Connecting bridge emqx (v6q9efjc.abc.cn-hangzhou.emqxsl.cn:8883)
1722343382: Bridge OpenWrt.emqx sending CONNECT
1722343382: mosquitto version 2.0.18 running
1722343384: Received CONNACK on connection local.OpenWrt.emqx.
1722343384: Bridge local.OpenWrt.emqx sending SUBSCRIBE (Mid: 2, Topic: mytopic, QoS: 0, Options: 0x0c)
1722343384: Received PUBACK from local.OpenWrt.emqx (Mid: 1, RC:16)
1722343384: Received SUBACK from local.OpenWrt.emqx
|