Cloud 将本地MOSQUITO桥接到云代理

Cloud 将本地MOSQUITO桥接到云代理,cloud,local,mqtt,mosquitto,bridge,Cloud,Local,Mqtt,Mosquitto,Bridge,我正在尝试将本地的mosquitto(在raspberry pi上)连接到某个云代理,这样我就可以发送数据并使用该数据控制一些设备。我尝试了Cloudmqtt和dioty,但没有成功。对于cloudmqtt,我被告知mosquito.conf文件一切正常,对于dioty,我被告知它使用不支持桥接的Mosca代理(我被告知我参考了cloudmqtt和dioty支持服务)。有人知道某个远程代理可以连接到本地mosquitto吗?有人已经尝试过了吗 我考虑过使用一些物联网平台来实现这一点,但我读过类似

我正在尝试将本地的mosquitto(在raspberry pi上)连接到某个云代理,这样我就可以发送数据并使用该数据控制一些设备。我尝试了Cloudmqtt和dioty,但没有成功。对于cloudmqtt,我被告知mosquito.conf文件一切正常,对于dioty,我被告知它使用不支持桥接的Mosca代理(我被告知我参考了cloudmqtt和dioty支持服务)。有人知道某个远程代理可以连接到本地mosquitto吗?有人已经尝试过了吗

我考虑过使用一些物联网平台来实现这一点,但我读过类似于使用定价的平台,我这样做是为了学习和霍比,所以在我学习如何使用它之前,我希望保持免费帐户

编辑: 我使用的mosquitto 1.4.5,mosquitto.conf文件如下:

#Place your local configuration in /etc/mosquitto/conf.d/
#
#A full description of the configuration file is at
#/usr/share/doc/mosquitto/examples/mosquitto.conf.example

connection cloudmqtt
address mnumber.cloudmqtt.com:port
topic zaESP8266 in 0
topic ESP8266 out 0
try_private true
notifications false
start_type automatic
remote_usename username_of_the_user_on_cloudmqtt
remote_password password_of the_user_on_cloudmqtt

pid_file /var/run/mosquitto.pid

persistance true
persistance_location /var/lib/mosquitto/
我之所以选择Cloudmqtt作为在线mosquitto代理,是因为我认为本地mosquitto远程mosquitto桥应该可以工作。我可以使用像笔记本电脑或电话这样的客户端,用它们来发布和订阅本地代理的消息。这样,即使我失去了互联网接入,我也可以让本地代理与本地客户进行交互

编辑: 我配置了mosquitto.conf文件,以便能够与test.mosquitto.org连接,我添加了以下行:

connection test
address test.mosquitto.org
topic in_topic in 0
topic out_topic out 0
try_private false
notifications false
bridge_attempt_unsubscribe true
现在,在一个终端中,我可以在主题中使用
mosquitto\u sub-t,在另一个终端中,我使用
mosquitto\u pub-h test.mosquitto.org-t in\u topic-m message
。我在第一个终端收到了这个消息,在那里我使用了mosquitto_sub命令。所以在这之后,我正确地假设这座桥运行良好。但是我不知道桥接到cloudmqtt的问题是什么

Cloudmqtt使用mosquitto mqtt代理,dioty从mosquitto交叉到Mosca mqtt代理,该代理不支持桥接,但显然具有更好的可扩展性(此信息已由dioty客户服务提供给我)

编辑: 我使用节点红色解决了这个bridgig问题。刚刚添加了一个mqqt输入,并为本地MOSQUITO代理(端口1883)配置它,为cloudmqtt和DIoTY配置两个mqtt输出

在cloudmqtt上,在您创建了一个帐户(cute cat是免费的)之后,转到控制面板并添加cloudmqtt实例,cloudmqtt将向您提供用户名和密码。在节点红色中,通过添加服务器、用户名、密码和端口,为cloudmqtt实例配置一个mqtt输出

在DIoTY上,您还需要创建帐户或登录google或其他帐户。当您登录时,您将通过用户名(即您的邮件帐户)和其他信息(如主机和端口)、密码(将发送到电子邮件帐户)提供信息。因此,要在节点RED中使用它,您需要将主机(服务器)、用户名、密码和端口添加到mqtt输出中。当您订阅或发布消息时,请记住您有根主题,例如:

/您的邮件帐户/主题

无论是订阅某个主题还是发布某些消息,都需要添加根主题作为某种前缀


完成此配置后,您需要部署更改,也就是说。因此,对于这种类型,我使用了节点RED。

您可以尝试test.mosquito.org作为远程代理


为了改进您的问题,请提供您正在使用的MOSQUITO版本的详细信息,并发布您使用的确切mosQUITO.conf设置-当然要删除凭据。

我正在使用windows和c9.io linux控制台测试


我发现

cloudmqtt.com服务器证书由Comodo签署,其根目录为AddTrust CA。默认情况下,大多数OSs都会附带它,因此您可以指向默认的trust/CA存储

获取AddTrust CA证书的方法 方法01

  • 单击开始,单击开始搜索,键入mmc,然后按ENTER键

  • 在文件菜单上,单击添加/删除管理单元

  • 在可用管理单元下,单击证书,然后单击添加

  • 下,此管理单元将始终管理的证书,单击计算机帐户,然后单击下一步

  • 单击本地计算机,然后单击完成

  • 如果没有更多的管理单元可添加到控制台,请单击“确定”

  • 在控制台树中,双击证书

  • 单击以受信任的根证书颁发机构证书存储

  • 右键单击AddTrust外部CA根目录

  • 单击导出导出导出证书,并按照证书导出向导中的步骤,导出文件格式选择导出Base-64编码的X.509(CER)

  • ca.cer保存到**C:\Program Files\mosquito**

  • 方法02

    我在这里获得证书:www.tbs-certificates.co.uk/FAQ/en/357.html

    添加信任CA根证书

  • 将AddTrustExternalCARoot.crt复制到C:\Program Files\MosQuito\
  • 双击AddTrustExternalCARoot.crt,安装证书

  • Mosquitto至CloudMQTT桥 窗口

    我使用的是mosquitto 1.4.11windowsmosquitto.conf文件我使用的是不同的名称(cloud.conf),它看起来像这样:

    #Place your local configuration in /etc/mosquitto/conf.d/
    #
    #A full description of the configuration file is at
    #/usr/share/doc/mosquitto/examples/mosquitto.conf.example
    
    connection cloudmqtt
    address mnumber.cloudmqtt.com:port
    topic zaESP8266 in 0
    topic ESP8266 out 0
    try_private true
    notifications false
    start_type automatic
    remote_usename username_of_the_user_on_cloudmqtt
    remote_password password_of the_user_on_cloudmqtt
    
    pid_file /var/run/mosquitto.pid
    
    persistance true
    persistance_location /var/lib/mosquitto/
    
    connectioncloudmqtt
    地址xxx.cloudmqtt.com:
    远程用户名
    远程密码
    远程clientid cloud.mqtt
    网桥协议版本mqttv311
    试试你的私人生活
    虚假通知
    启动类型自动
    主题#两个都是2
    #
    
    C:\Program Files\mosquitto> mosquitto.exe -c cloud.conf -v
    
    1490627692: mosquitto version 1.4.11 (build date 20/02/2017 23:24:29.40) starting
    1490627692: Config loaded from cloud.conf.
    1490627692: Opening ipv6 listen socket on port 1883.
    1490627692: Opening ipv4 listen socket on port 1883.
    1490627692: Bridge local.mosquitto doing local SUBSCRIBE on topic #
    1490627692: Connecting bridge cloudmqtt (xxx.cloudmqtt.com:<ssl-port>)
    1490627692: Bridge cloud.mqtt sending CONNECT
    1490627693: Received CONNACK on connection local.mosquitto.
    1490627693: Bridge local.mosquitto sending SUBSCRIBE (Mid: 1, Topic: #, QoS: 2)
    1490627693: Received SUBACK from local.mosquitto
    ...
    
    $ mosquitto -c cloud.conf -v -p 8080
    1490634446: mosquitto version 1.4.11 (build date Fri, 03 Mar 2017 15:11:39 +0000) starting
    1490634446: Config loaded from cloud.conf.
    1490634446: Opening ipv4 listen socket on port 8080.
    1490634446: Opening ipv6 listen socket on port 8080.
    1490634446: Bridge c9.mosquitto doing local SUBSCRIBE on topic #
    1490634446: Connecting bridge cloudmqtt2c9 (xxx.cloudmqtt.com:<ssl-port>)
    1490634446: Connecting bridge cloudmqtt2c9 (xxx.cloudmqtt.com:<ssl-port>)
    1490634446: Bridge cloud.mqtt.c9 sending CONNECT
    1490634446: Received CONNACK on connection c9.mosquitto.
    1490634446: Bridge c9.mosquitto sending SUBSCRIBE (Mid: 1, Topic: #, QoS: 2)
    1490634447: Received SUBACK from c9.mosquitto
    ...
    
    connection pi2cloudmqtt
    address xxx.cloudmqtt.com:<ssl-port>
    remote_username <username_of_the_user_on_cloudmqtt>
    remote_password <password_of the_user_on_cloudmqtt>
    remote_clientid cloud.mqtt.pi
    bridge_protocol_version mqttv311
    try_private true
    notifications false
    start_type automatic
    topic # both 2
    # Method 01
    #bridge_cafile ca.cer
    # Method 02
    bridge_cafile AddTrustExternalCARoot.crt
    bridge_insecure false
    cleansession false
    local_clientid pi.mosquitto