Skip to content

fix(iot-dev): Fix how the client handles failed disconnections#1338

Merged
timtay-microsoft merged 9 commits intomasterfrom
timtay/close
Sep 10, 2021
Merged

fix(iot-dev): Fix how the client handles failed disconnections#1338
timtay-microsoft merged 9 commits intomasterfrom
timtay/close

Conversation

@timtay-microsoft
Copy link
Copy Markdown
Member

Previously, the SDK would throw an exception if the service didn't respond to the mqtt/amqp disconnect messages and it would leave the SDK in a weird semi-closed state.

This change makes it so that the close logic in our transport layers always cleans up the local resources even if the service doesn't respond to the disconnection in a timely manner

Previously, the SDK would throw an exception if the service didn't respond to the mqtt/amqp disconnect messages and it would leave the SDK in a weird semi-closed state.

This change makes it so that the close logic in our transport layers always cleans up the local resources even if the service doesn't respond to the disconnection in a timely manner

// reconnection may have failed, so check last retry decision, check for timeout, and check if last exception
// was terminal
try
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is a bit hard to see the diff on, but basically the try/catch was removed since the caught exception is no longer thrown

{
// As per the documentation for mqttAsyncClient.close() this exception is only thrown if the client is already
// closed. No need to re-attempt anything here.
log.debug("Mqtt client was already closed, so ignoring the thrown exception", ex);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to double check that the exception is a part of this log statement

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this does work the way I thought. Even though there is no "{}" space for it, log.debug knows to print the exception with the base message

@DBY047
Copy link
Copy Markdown

DBY047 commented Sep 10, 2021

Anybody to review this PR for @timtay-microsoft? I need this fix ASAP. I can cheery-pick the commits unless you plan to change the code.

Thanks,

@Azure Azure deleted a comment from azure-pipelines Bot Sep 10, 2021
@Azure Azure deleted a comment from azure-pipelines Bot Sep 10, 2021
@Azure Azure deleted a comment from azure-pipelines Bot Sep 10, 2021
@Azure Azure deleted a comment from azure-pipelines Bot Sep 10, 2021
@Azure Azure deleted a comment from azure-pipelines Bot Sep 10, 2021
@Azure Azure deleted a comment from azure-pipelines Bot Sep 10, 2021
@timtay-microsoft timtay-microsoft merged commit d566a57 into master Sep 10, 2021
@timtay-microsoft timtay-microsoft deleted the timtay/close branch September 10, 2021 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants