wolfSSL / wolfMQTT

wolfMQTT is a small, fast, portable MQTT client implementation, including support for TLS 1.3.
https://www.wolfssl.com
GNU General Public License v2.0
521 stars 155 forks source link

MqttSocket_Write "client->write.pos" not reset when socket write fail #289

Closed trzhongty closed 2 years ago

trzhongty commented 2 years ago

mqtt_socket.c MqttSocket_Write

In blocking mode, "client->write.pos" is not reset when the "MqttSocket_WriteDo" result is less than 0. which in turn causes the wrong offset data to be sent when trying to reconnect, further errors until "client->write.pos >= buf_len"

Or should I have to clear client all on reconnect?

embhorn commented 2 years ago

Hi @trzhongty

Yes, you are correct, the client structure should be re-initialized prior to attempting a reconnect due to an error or broker disconnect.

Thanks, Eric @ wolfSSL Support

trzhongty commented 2 years ago

Thanks