Description
Hi Andreas and thanks for sharing this example. I appreciate it's a few years old and as you already explained in a few of the other closed issues you don't have the time to check it anymore but this issue is really trivial to fix and requires next to no time from your side - change just one character in the code :)
I played with your example on an esp32 and it works for a few hours and then it just freezes without any obvious reason. mosquitto would log "Socket error on client <client_id>, disconnecting" multiple times and nothing would work from that point on until the esp32 would be reset, when it would suddenly work again, and the cycle would repeat. (and no, it's not related to bad wifi signal, I checked it on the router)
Looking at your code I believe this is a typo and you probably meant to write "i < 10", not "i > 10":
for (int i = 0; i > 10; i++) {
MQTTclient.loop();
delay(100);
}
Because of this typo the loop()'s are never actually executed. Not sure how much of a problem this would create if you're not actually expecting any mqtt messages in the client (like in this one) but I still think it wouldn't hurt to change "i > 10" to "i < 10", just in case it helps. I just reflashed the esp32 with the updated version and I'll leave it overnight to see if it makes any difference to the stability.