Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to get MQTT error code after calling AzureIoTHubClient_Connect() #320

Open
2 tasks done
rtheil-growlink opened this issue Oct 11, 2023 · 1 comment
Open
2 tasks done
Assignees
Labels
enhancement New feature or request

Comments

@rtheil-growlink
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Version

1.4.0

Description of the issue

A need has become apparent that we need to know the MQTT error status when attempting to establish the MQTT connection, and it fails. We need to be able to control reconnection behavior based on the error code returned for the MQTT connection.

in AzureIoTHubClient_Connect(), there is AzureIoTMQTTResult_t xMQTTResult. There doesn't seem to be a way to have that value returned, or even stored in pxAzureIoTHubClient._internal.MQTTContext

After a network outage yesterday to our IoT Hub, we found that not only our ESP devices, but also our IoT Edge devices, all came back online at exactly at the same time and caused a flood of traffic writing reported properties, which caused throttling, resulting in thousands of devices being unable to come back online for quite some time. It would be nice to control a backoff algorithm based on that specific error (eAzureIoTMQTTNoDataAvailable), so that we can ensure some level of randomness when this type of event happens in the future. We've also seen the need to handle other MQTT errors differently, such as eAzureIoTMQTTServerRefused, which can occur when there is a >5 minute time difference between client and server. eAzureIoTMQTTNoMemory could be a sign of a need to reboot or alert of a memory leak.

Hopefully this data is available somewhere and I'm just not seeing it, otherwise I believe this would be a good feature to add to this library. I would argue that this would also be useful when calling _ProcessLoop(), as some MQTT errors warrant an immediate retry, especially when connectivity is poor. We have a number of customers with incredibly poor internet connections, including point-to-point, satellite, and rural cellular.

As always, thanks for everything you do on this project!

Expected behavior

No response

Steps to reproduce the issue

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ericwolz ericwolz self-assigned this Dec 14, 2023
@ericwolz ericwolz added the enhancement New feature or request label Dec 14, 2023
@ericwolz
Copy link
Contributor

ericwolz commented Dec 14, 2023

Thanks for your feedback here. We have these items in our backlog. Currently we don't do connection management, but is a highly requested feature that we will try to address in a future release.

Current expectation is that the application implement a backoff algorithm.
https:/Azure-Samples/iot-middleware-freertos-samples/blob/794c4936e6573baa636f44f78d8e3878cd49fdfa/demos/sample_azure_iot/sample_azure_iot.c#L615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants