我的IoT项目遇到一些问题后,请参见以下主题: Mosquitto Broker Bridge Configuration - unacceptable protocol version实现网桥连接还有一个问题。
我在安装了Raspbian Stretch的Raspberry Pi上使用Mosquitto v1.6.7。 mosquitto代理桥与远程代理(SAP IoT Cloud)之间的连接无法建立。我再次仔细检查了所有设置(端点地址正确,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
答案 0 :(得分:0)
来自mosquitto.conf男人page
远程客户端ID
设置此网桥连接的客户端ID。如果未定义,则此 默认为'name.hostname',其中name是连接名称, hostname是这台计算机的主机名。
这将替换旧的“ clientid”选项,以避免与 桥梁的本地/远端。 “ clientid”对于 暂时。
这意味着提供给远程代理的clientid是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 all