adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support
MIT License
572 stars 291 forks source link

Silent Limit on the number of subscribed topics, callback ignored #219

Open joihn opened 1 year ago

joihn commented 1 year ago

Env: Esp8266, communication via TLS

Symptom: When too many subscriber are registered, the last few one will never execute their callback.

reproducing Subscribe to multiple topics (17 in my case) with this syntax

Adafruit_MQTT_Subscribe trigg1 = Adafruit_MQTT_Subscribe(&mqtt, "triggTopic1", MQTT_QOS_1);
trigg1.setCallback(foo);
mqtt.subscribe(&trigg1);
Adafruit_MQTT_Subscribe trigg2 = Adafruit_MQTT_Subscribe(&mqtt, "triggTopic2", MQTT_QOS_1);
trigg1.setCallback(bar);
mqtt.subscribe(&trigg2);

etc... The last few subsriber will get ignored, silently (!!!!!) (they will never execute their callback, despite a successfull compilation, thus very confusing to debug ) There seems to be a silent hidden limit on the max. number of subscribed topics.

joihn commented 1 year ago

there is indeed a limit https://github.com/adafruit/Adafruit_MQTT_Library/blob/master/Adafruit_MQTT.h#L126

Maybe a verbose failure when exceeding it would be a good idea.