Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

PublishState Causes Disconnection

Gal Zahavi edited this page Jul 1, 2020 · 1 revision

The Error:

If you use the cloud console to send a config to a device, it will receive a message on /config when it next reconnects. Responding to this message with a publishState will cause disconnection (and the same will happen again on every reconnection).

The Solution:

ESP is having issues context switching between the publish and receive operations. Another potential source of the issue is that due to the "at > least once delivery" nature of PubSub messages the callback could get triggered multiple times before the state messages are sent. You are limited to transmitting one state message per second and this potentially could cause a disconnect.

I would recommend the following:

  • Create a queue of state messages
  • Append to the queue in the callback
  • Dequeue the state message[s] and transmit them outside of the callback.