Imroy / pubsubclient

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

OTA over MQTT #64

Closed ionciubotaru closed 7 years ago

ionciubotaru commented 7 years ago

I tried OTA using test.mosquitto.org The update works fine except:

    Serial.println("Clearing retained message.");
    client.publish(MQTT::Publish(pub.topic(), "")
                   .set_retain());

Client doesn't publish anything, so ESP update again and again I tried:

    Serial.println("Clearing retained message.");
    client.publish(MQTT::Publish(pub.topic(), "")
                   .set_retain(true));

but it doesn't work - nothing is published on mqtt server.

THKDev commented 7 years ago

Remove pub.payload_stream()->stop(); Do NOT stop the client connection because the (WiFi) Client hold in class Publish is NOT ref counted. It is only a pointer. Closing it will count ref to 0 and close the TCP connection.