Imroy / pubsubclient

A client library for the ESP8266 that provides support for MQTT
MIT License
434 stars 115 forks source link

client.loop() should return after ONE message received #42

Open Suxsem opened 8 years ago

Suxsem commented 8 years ago

I have this problem: I have a lot (about 10) topics that have retained messages. After connecting to the broker I subscribe to all of them in one call to client.subscribe. I start to receive the retained messages but after some of them the esp8266 freezes.

I put some debug instructions inside the callback function and before and after client.loop(): Serial.println("before"); client.loop(); Serial.println("after"); delay(500);

This is what i get: before new message new message new message

and then the esp8266 freezes. the delay is never called. So, why client.loop() processes more then one message? How can i slow it down to prevent esp8266 from freezing when it receives a lot of messages at the same time?

I'm using QOS 2 for all pub/sub operations.

Suxsem commented 8 years ago

p.s. when the esp8266 freezes I still have a lot of free ram (more then 40k). in mosquitto I got "Socket error on client ***, disconnecting" right when it freezes (mosquitto doesn't seems to need the missing keepalive packet to understand that the esp8266 freezed)