256dpi / arduino-mqtt

MQTT library for Arduino
MIT License
1.01k stars 232 forks source link

mqtt client usable to connect to 2 mqtt brokers? #229

Closed pottendo closed 3 years ago

pottendo commented 3 years ago

hi,

thanks for this nice lib. I use it on an esp32/arduino. I experience some issues to connect to two mqtt brokers from one application:

the first connection is stable, however the second seems to be unstable. Only a fraction of the expected messages are being received on the broker side.

Can anyone here confirm that 2 client instances can be used from one application? Or the other way round, by confirming that the lib is not thread-safe enough or not supporting 2 or more client connections.

thanks, pottendo

PS: my code instantiates 2 MQTTBroker clients and configures 2 brokers respectively. I've put a mutex to protect against concurrent calls to the publish() method. the second client doen't subscribe to any subjects - it's just supposed to publish.

pottendo commented 3 years ago

hi, it seems that I've stumbled over the message size limit - having added a time-stamp, I've create messages longer than the default of 128bytes. I've increased the message size, and now it seems to work as expected. Sorry for the noise, pottendo