ESP8266无法通过AWS IoT核心版通过MQTT接收消息 [英] ESP8266 failing to receive message over MQTT via AWS IoT Core
问题描述
我正在根据
I'm using PubSubClient per this example to connect to AWS IoT. Specifically, I'm trying to use AWS IoT Fleet Provisioning, which involves subscribing and publishing to some special $aws/
topics.
连接正确建立,并且CloudWatch日志显示成功的 Connect
, Subscribe
, Publish-In
和 Publish-Out
事件.但是,每当MCU收到一条消息时,它似乎就会断开连接.有什么作用?
The connection is being established correctly, and CloudWatch logs show successful Connect
, Subscribe
, Publish-In
and Publish-Out
events. However, whenever the MCU receives a message, it appears to drop the connection. What gives?
推荐答案
调试PubSubClient显示底层的 WiFiClientSecure
实例由于以下错误而失去连接:
Debugging PubSubClient showed that the underlying WiFiClientSecure
instance was losing connection due to the following error:
BR_ERR_TOO_LARGE: Incoming record is too large to be processed, or buffer is too small for the handshake message to send.
我收到的消息约为4 KB,因此我必须添加以下内容:
The message I was receiving was about 4 KB, so I had to add the following:
wifi_ = new WiFiClientSecure();
wifi_->setBufferSizes(4096, 512);
从那里开始,PubSubClient有了自己的缓冲区,我也不得不提高它:
From there, it turned out PubSubClient had its own buffer, which I also had to raise:
mqtt_ = new PubSubClient(*wifi_);
mqtt_->setBufferSize(4096);
进行这些更改使我能够成功地从AWS IoT接收这些消息.
Making these changes allowed me to receive these messages from AWS IoT successfully.
这篇关于ESP8266无法通过AWS IoT核心版通过MQTT接收消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!