0

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.

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?

Oleg Vaskevich
  • 12,444
  • 6
  • 63
  • 80

1 Answers1

0

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.

The message I was receiving was about 4 KB, so I had to add the following:

  wifi_ = new WiFiClientSecure();
  wifi_->setBufferSizes(4096, 512);

From there, it turned out PubSubClient had its own buffer, which I also had to raise:

  mqtt_ = new PubSubClient(*wifi_);
  mqtt_->setBufferSize(4096);

Making these changes allowed me to receive these messages from AWS IoT successfully.

Oleg Vaskevich
  • 12,444
  • 6
  • 63
  • 80