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

Moderator: ESP_XCGuang

fst202130609
Posts: 171
Joined: Thu Sep 23, 2021 10:03 am

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

Postby fst202130609 » Wed Mar 02, 2022 1:15 am

我使用官方给的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

ESP_Sun
Posts: 326
Joined: Thu Dec 30, 2021 9:52 am

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

Postby ESP_Sun » Wed Mar 02, 2022 2:40 am

你可以根据文档(https://blog.csdn.net/espressif/article ... /107367189)尝试看是否可以连接阿里云成功。

fst202130609
Posts: 171
Joined: Thu Sep 23, 2021 10:03 am

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

Postby fst202130609 » Wed Mar 02, 2022 3:08 am

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

fst202130609
Posts: 171
Joined: Thu Sep 23, 2021 10:03 am

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

Postby fst202130609 » Wed Mar 02, 2022 3:19 am

我设置了client ID,用户名,密码,为啥我用AT+MQTTCONN?指令还是:+MQTTCONN:0,2,1,"","","",0
05.png

ESP_Sun
Posts: 326
Joined: Thu Dec 30, 2021 9:52 am

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

Postby ESP_Sun » Wed Mar 02, 2022 3:42 am

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

fst202130609
Posts: 171
Joined: Thu Sep 23, 2021 10:03 am

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

Postby fst202130609 » Wed Mar 02, 2022 3:47 am

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

怎么抓包?

ESP_Sun
Posts: 326
Joined: Thu Dec 30, 2021 9:52 am

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

Postby ESP_Sun » Wed Mar 02, 2022 3:51 am

AT+MQTTCONN? 是查不到 name,id,password 的
企业微信截图_16461930028856.png
企业微信截图_16461930028856.png (62.66 KiB) Viewed 9705 times
企业微信截图_16461929949502.png
企业微信截图_16461929949502.png (27.74 KiB) Viewed 9705 times

ESP_Sun
Posts: 326
Joined: Thu Dec 30, 2021 9:52 am

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

Postby ESP_Sun » Wed Mar 02, 2022 3:53 am

您可以看一下这个文档 https://docs.espressif.com/projects/esp ... guide.html 来抓包。

fst202130609
Posts: 171
Joined: Thu Sep 23, 2021 10:03 am

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

Postby fst202130609 » Wed Mar 02, 2022 4:01 am

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环境

fst202130609
Posts: 171
Joined: Thu Sep 23, 2021 10:03 am

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

Postby fst202130609 » Wed Mar 02, 2022 4:25 am

在使用esp-at指令之前是不是还要操作这个
06.png

Who is online

Users browsing this forum: No registered users and 50 guests