knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.82k stars 1.47k forks source link

Delay in receiving payloads #954

Open gianlucaf81 opened 2 years ago

gianlucaf81 commented 2 years ago

I am using the library with an esp32 and arduino ide. My program is quite large, over 1000 lines of code. Is a thermostat that reads temperatures with thermocouple and max6675 (and a DS18b20), writes on 16X2 display. The publication of data (temperatures and time) on a mosquitto server on a synology nas and everything works perfectly, the publication does not miss a beat. However, if I send a command to my program, the command takes from 3 to 30 seconds to be seen. I spent several hours checking that there were no dead loops in my program but I found nothing strange. I wonder if the use of the probes and the display at the same time could create some problem or bottleneck in the library. Any suggestions are welcome. I also suspect that using strings inside the callback function can create this kind of problem.

gianlucaf81 commented 2 years ago

Oh... i found my mistake. I had subscribed to all the channels, even the outgoing ones. I didn't understand how it works. now it works perfectly. Thx

mandgeo commented 1 year ago

I have similar problem. Two esp32 doing different things, with the same publish & callback routines. One of them is receiving when it should. The other one receiving with delay. And the delay gets larger as the time passes. Like receiving from a buffer. Everything is sent/received as qos 0, the device is subscribed to a dedicated topic. Any other ideas?