From 0e2d6c322bba946ea9fc3a4e5d2d0dfe9070db3b Mon Sep 17 00:00:00 2001 From: Folkert van Heusden Date: Fri, 7 Sep 2018 21:39:45 +0200 Subject: [PATCH] Update PubSubClient.cpp Make sure all data is flushed to the other end when doing a disconnect(): that way we know for sure that it is there when we disconnect the wifi or maybe even reboot. This change was made after I noticed that I did not get any mqtt messages. I verified that it indeed solves the problem. Example code on request. --- src/PubSubClient.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PubSubClient.cpp b/src/PubSubClient.cpp index 29fbbfa..3c5c5f7 100755 --- a/src/PubSubClient.cpp +++ b/src/PubSubClient.cpp @@ -524,6 +524,7 @@ void PubSubClient::disconnect() { buffer[1] = 0; _client->write(buffer,2); _state = MQTT_DISCONNECTED; + _client->flush(); _client->stop(); lastInActivity = lastOutActivity = millis(); }