本文介绍了ESP8266无法通过AWS IoT核心版通过MQTT接收消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在根据 PubSubClient debsahu/ESP-MQTT-AWS-IoT-Core"rel =" nofollow noreferrer>此示例以连接到AWS IoT.具体来说,我正在尝试使用 AWS IoT Fleet Provisioning ,其中涉及订阅和发布一些特殊的 $ aws/主题.

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接收消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-13 13:02