使用BG96和MQTT协议将数据发布到AWS IoT时出错 [英] error when publish data to aws IoT using BG96 and MQTT protocol
问题描述
我正在尝试使用BG96(使用AT命令的NB-IoT设备)将数据发布到Amazon Web服务 我正在关注官方文档(Quectel) 所以我配置SSL参数(使用命令:at + qsslcfg = ...)并成功启动MQTT SSL连接(AT + QMTOPEN = ...),但是当我尝试连接到MQTT服务器时(AT + QMTCONN = ...) ,连接立即关闭 请帮忙,如何解决此问题并将数据发布到Amazon Web服务?
I'm trying to publish my data to Amazon web services using BG96 (NB-IoT device that use AT commands) I'm following the official documentation (Quectel) so I configure SSL parameters ( with the command : at+ qsslcfg=...) and start MQTT SSL connection successfully (AT+QMTOPEN=...) but when I try to connect to MQTT server( AT+QMTCONN=...), the connection is closed immediately Please help,how can I fix this problem and publish my data to Amazon web services ?
AT+QSSLCFG="ciphersuite",1,0x0035
OK
AT+QSSLCFG="sslversion",1,3
OK
AT+QSSLCFG="cacert",1,"ufs:cacert.pem"
OK
AT+QSSLCFG="clientcert",1,"ufs:clientcert.pem"
OK
AT+QSSLCFG="clientkey",1,"ufs:clientkey.pem"
OK
AT+QSSLCFG="seclevel",1,2
OK
AT+QSSLCFG="negotiatetime",1,300
OK
AT+QSSLCFG="ignorelocaltime",1,0
OK
//Configure MQTT session into SSL mode.
AT+QMTCFG="SSL", 0, 1, 1
//Start MQTT SSL connection
AT+QMTOPEN=0, "a2xxxxxxxxxzxx.iot.us-east-1.amazonaws.com","8883"
OK // ok
+QMTOPEN: 0,0 // means the connction is starts succsesfully
//Connect to MQTT server
AT+QMTCONN=0,"bg96"
ok
+QMTSTAT 0,1 //but this message means that the connection is closed
推荐答案
我找到了解决方案, 我的问题是,我应该创建一个允许连接到AWS的策略,并将该策略附加到我创建的对象上, 如果使用nb-iot,则应将DNS地址配置为Google公用DNS:8.8.8.8和8.8.4.4 当然,请专心发出所有命令以更新证书,配置ssl上下文,激活tcp上下文并最终打开mqtt连接并连接以发布或订阅主题
I find the solution , My problem is that I should create a policy to allow connection to aws and attach this policy to the thing that I create , If nb-iot is used then we shoud configure the DNS address to Google public DNS : 8.8.8.8 and 8.8.4.4 And of course issue all commands attentively to update certificates , configure ssl context , activate tcp context and finally open mqtt connection and connect to publish or subscribe to topic
这篇关于使用BG96和MQTT协议将数据发布到AWS IoT时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!