在我的IoT项目上遇到一些问题后,请参阅这个帖子:Mosquitto Broker Bridge Configuration - unacceptable protocol version我仍然有一个问题来实现桥接连接。
我在安装了Raspbian Stretch的Raspberry Pi上使用Mosquitto v1.6.7。未能建立蚊子到代理桥和远程代理(SAP IoT云)之间的连接。我已经再次检查了所有设置(端点地址是正确的,CAcert.pem与我在没有网桥的情况下从客户端发送到远程代理时使用的是相同的,任何提示都非常感谢!)
下面是我更新后的蚊子代理配置:
我已经解除了连接名称和地址的个性化。连接名称在远程代理(SAP Cloud)中用作clientId,并经过仔细检查,端点地址也是如此。
listener 8883
connection raspberryPiZero
address xxxxxxxx.eu10.cp.iot.sap:8883
bridge_protocol_version mqttv311
try_private false
topic # both
log_type all
bridge_cafile /etc/mosquitto/certs/CAcert.pem以下是更新后的日志文件:
1574766394: mosquitto version 1.6.7 starting
1574766394: Config loaded from /etc/mosquitto/conf.d/local.conf.
1574766394: Opening ipv4 listen socket on port 8883.
1574766394: Opening ipv6 listen socket on port 8883.
1574766394: Bridge local.raspberrypi.raspberryPiZero doing local SUBSCRIBE on topic #
1574766394: Connecting bridge (step 1) raspberryPiZero (xxxxxxxx.eu10.cp.iot.sap:8883)
1574766395: Connecting bridge (step 2) raspberryPiZero (xxxxxxxx.eu10.cp.iot.sap:8883)
1574766395: Bridge raspberrypi.raspberryPiZero sending CONNECT
1574766395: Received CONNACK on connection local.raspberrypi.raspberryPiZero.
1574766395: Connection Refused: broker unavailable
1574766395: Socket error on client local.raspberrypi.raspberryPiZero, disconnecting.
1574766400: Bridge local.raspberrypi.raspberryPiZero doing local SUBSCRIBE on topic #
1574766400: Connecting bridge (step 1) raspberryPiZero (xxxxxxxx.eu10.cp.iot.sap:8883)
1574766401: Connecting bridge (step 2) raspberryPiZero (xxxxxxxx.eu10.cp.iot.sap:8883)
1574766401: Bridge raspberrypi.raspberryPiZero sending CONNECT
1574766401: Received CONNACK on connection local.raspberrypi.raspberryPiZero.
1574766401: Connection Refused: broker unavailable
1574766401: Socket error on client local.raspberrypi.raspberryPiZero, disconnecting.
1574766406: Bridge local.raspberrypi.raspberryPiZero doing local SUBSCRIBE on topic #
1574766406: Connecting bridge (step 1) raspberryPiZero (xxxxxxxx.eu10.cp.iot.sap:8883)
1574766407: Connecting bridge (step 2) raspberryPiZero (xxxxxxxx.eu10.cp.iot.sap:8883)
1574766407: Bridge raspberrypi.raspberryPiZero sending CONNECT
1574766407: mosquitto version 1.6.7 terminating发布于 2019-11-26 20:55:12
来自mosquitto.conf man page
remote_clientid id
设置此桥接连接的客户端id。如果未定义,则默认为'name.hostname',其中name是连接名称,hostname是此计算机的主机名。
这替换了旧的"clientid“选项,以避免与桥的本地/远程侧混淆。clientid暂时保持有效。
这意味着呈现给远程代理的客户端is是raspberryPiZero.raspberrypi而不是raspberryPiZero。如果客户端id只需要为raspberryPiZero,那么您需要使用remote_clientid选项来设置它。
这将使客户端id正确。接下来,您需要告诉本地代理使用与客户端使用的所有证书相同的证书。
您需要使用bridge_certfile指向客户端证书文件,使用bridge_keyfile指向未加密的客户端私钥。
connection raspberryPiZero
address xxxxxxxx.eu10.cp.iot.sap:8883
bridge_protocol_version mqttv311
remote_clientid raspberryPiZero
try_private false
bridge_cafile /etc/mosquitto/certs/CAcert.pem
bridge_certfile /etc/mosquitto/certs/clientCert.pem
bridge_keyfile /etc/mosquitto/certs/clientKey.pem
topic # both
log_type allhttps://stackoverflow.com/questions/59049919
复制相似问题