awslabs / aws-crt-nodejs

NodeJS bindings for the AWS Common Runtime.
Apache License 2.0
37 stars 24 forks source link

Adjust MQTT311 disconnect cleanup #455

Closed TwistedTwigleg closed 1 year ago

TwistedTwigleg commented 1 year ago

Description of changes:

~Adjusts MQTT311's disconnect behavior to not always free the native resources when disconnect() is called, instead adding a new option (close_on_disconnect) that can be set to false, allowing for manual reconnects. Also exposes the close() function so the connection can be cleaned manually if close_on_disconnect is set to false.~

~Also fixes a number of segfaults that can occur if the MQTT311 connection is closed. Now errors are thrown explaining that the MQTT311 connection has been closed and is no longer usable, rather than segfaulting.~

~Adding documentation for these new functions and tests to ensure functionality works as expected by default, and with the new option.~

Fixes segfaults that occur when you call connect, disconnect, and then connect again, or if you call disconnect and then try to perform any other operations (subscribe, unsubscribe, publish, etc). Also adjusts documentation a bit, and adds a couple tests to ensure the current behavior works as expected without segfaults.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

TwistedTwigleg commented 1 year ago

Thanks! Merging into main...