Page 1 of 2

esp-at使用at指令来连接阿里云失败

Posted: Wed Mar 02, 2022 1:15 am
by fst202130609
我使用官方给的esp32c3固件烧录,我自己使用的是esp32c3-min-1,先用at指令来连接WiFi,然后用at指令来设置服务器的信息:AT+MQTTUSERCFG=0,7,"12345","UserName","UserPassword",0,0,"" 返回OK
再用at指令连接到 MQTT Brokers:AT+MQTTCONN=0,"xxxxxx.iot-as-mqtt.cn-shanghai.aliyuncs.com",1883,0 返回失败,串口打印报错日志:
all parameters are ready [0;31mE (33344) TRANSPORT_WS: Error read response for Upgrade header GET / HTTP/1.1 Connection: Upgrade Host: a1iLwGnfcuL.iot-as-mqtt.cn-shanghai.aliyuncs.com:1883 User-Agent: ESP32 Websocket Client Upgrade: websocket Sec-WebSocket-Version: 13 Sec-WebSocket-Key: FAZBI51XQMCOOpXJJSqudg== Sec-WebSocket-Protocol: mqtt [0m
[0;31mE (33363) MQTT_CLIENT: Error transport connect[0m
MQTT ERROR MQTT DISCONNECTED

Re: esp-at使用at指令来连接阿里云失败

Posted: Wed Mar 02, 2022 2:40 am
by ESP_Sun
你可以根据文档(https://blog.csdn.net/espressif/article ... /107367189)尝试看是否可以连接阿里云成功。

Re: esp-at使用at指令来连接阿里云失败

Posted: Wed Mar 02, 2022 3:08 am
by fst202130609
ESP_Sun wrote:
Wed Mar 02, 2022 2:40 am
你可以根据文档(https://blog.csdn.net/espressif/article ... /107367189)尝试看是否可以连接阿里云成功。
我按照步骤来做还是不行,我在mqtt.fx可以连接,用at来不行
02.png
03.png
04.png

Re: esp-at使用at指令来连接阿里云失败

Posted: Wed Mar 02, 2022 3:19 am
by fst202130609
我设置了client ID,用户名,密码,为啥我用AT+MQTTCONN?指令还是:+MQTTCONN:0,2,1,"","","",0
05.png

Re: esp-at使用at指令来连接阿里云失败

Posted: Wed Mar 02, 2022 3:42 am
by ESP_Sun
AT+MQTTCONN? 查询到的结果是正确的,AT+MQTTCONN 文档:https://docs.espressif.com/projects/esp ... qtt-broker,对于连接不上的问题可以抓包看下

Re: esp-at使用at指令来连接阿里云失败

Posted: Wed Mar 02, 2022 3:47 am
by fst202130609
ESP_Sun wrote:
Wed Mar 02, 2022 3:42 am
AT+MQTTCONN? 查询到的结果是正确的,AT+MQTTCONN 文档:https://docs.espressif.com/projects/esp ... qtt-broker,对于连接不上的问题可以抓包看下
AT+MQTTCONN?命令不是查询是否连接mqtt-broker吗?那我设置了用户名,clientid,密码,结果返回:+MQTTCONN:0,2,1,"","","",0

怎么抓包?

Re: esp-at使用at指令来连接阿里云失败

Posted: Wed Mar 02, 2022 3:51 am
by ESP_Sun
AT+MQTTCONN? 是查不到 name,id,password 的
企业微信截图_16461930028856.png
企业微信截图_16461930028856.png (62.66 KiB) Viewed 9682 times
企业微信截图_16461929949502.png
企业微信截图_16461929949502.png (27.74 KiB) Viewed 9682 times

Re: esp-at使用at指令来连接阿里云失败

Posted: Wed Mar 02, 2022 3:53 am
by ESP_Sun
您可以看一下这个文档 https://docs.espressif.com/projects/esp ... guide.html 来抓包。

Re: esp-at使用at指令来连接阿里云失败

Posted: Wed Mar 02, 2022 4:01 am
by fst202130609
ESP_Sun wrote:
Wed Mar 02, 2022 3:53 am
您可以看一下这个文档 https://docs.espressif.com/projects/esp ... guide.html 来抓包。
我mqtt已经初始化了,那我用这个AT+MQTTCONN=0,"a1iLwGnfcuL.iot-as-mqtt.cn-shanghai.aliyuncs.com",1883,1,为啥返回失败,我是在Windows里编译esp-idf的,没用Linux环境

Re: esp-at使用at指令来连接阿里云失败

Posted: Wed Mar 02, 2022 4:25 am
by fst202130609
在使用esp-at指令之前是不是还要操作这个
06.png