ESP8266 无法通过 AWS IoT Core 通过 MQTT 接收消息 [英] ESP8266 failing to receive message over MQTT via AWS IoT Core

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

问题描述

我正在使用 PubSubClient 每个 本示例 以连接到 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 日志显示成功 ConnectSubscribePublish-InPublish-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?

推荐答案

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆