256dpi / arduino-mqtt

MQTT library for Arduino
MIT License
1.01k stars 232 forks source link

Unwanted side effect of MQTT publish (Connection Close) #264

Closed thehellmaker closed 1 year ago

thehellmaker commented 3 years ago

In the code here (https://github.com/256dpi/arduino-mqtt/blob/master/src/MQTTClient.cpp#L333 ) its closing the connection when publish fails. Publish can fail for multiple reasons some temporary and some permanent. In my case the failures are temporary and retrying succeeds. Closing the connection makes this really unstable. The library should only tell if the publish was successful or not (with the right error code) and it should be the responsibility of the caller to close the connection or retry publish

thehellmaker commented 3 years ago

Please let me know if this makes sense. I will open a pr for removing this close from publish.

256dpi commented 3 years ago

A publish can only fail due to network issues. I don't think the Arduino API specifies temporary errors ATM. Therefore, if that happens, we need to properly close the socket to ensure everything is in the correct state.

256dpi commented 1 year ago

Closing for now. Please reopen if issues persists.