Closed jenscski closed 1 year ago
Hi @jenscski, thank you so much for evaluating previews/v2 and reporting this issue. I was able to reproduce and fix the issue, you can find the latest code changes here: https://github.com/Azure/azure-iot-sdk-csharp/pull/3359
Please let me know if it still does not work for you or if you face any more issues.
Hi @tmahmood-microsoft, we had similar issue and I was able to verify that your fix solves it. Can you publish new preview package which includes this?
@helynranta thank you for confirming the fix. Yes I am currently in process of publishing a new preview package. Should have it for you in a day or two.
Hi @helynranta, @jenscski I am attaching link to the latest release package for v2 preview containing this fix, please let me know if you face any more issues and thank you for evaluating the preview release.
https://github.com/Azure/azure-iot-sdk-csharp/releases/tag/preview_2023-08-14
Context
Description of the issue
When a connection is automatically reconnected (e.g. network drop or similiar), direct method calls is called twice (possibly one more for each reconnect)
I have tested with both disabling my network, and turning "Enable connection to IoT Hub" on and off.
The reason for the error is that MqttTransportHandler.OpenAsync is called upon reconnect, but MqttTransportHandler.CloseAsync is not, so the HandleReceivedMessageAsync method is added again to the MqttClient.ApplicationMessageReceivedAsync event.
Code sample exhibiting the issue
Console log of the issue