Skip to content

Additional Bug Fixes when Internet is not available #44

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 6 commits into from

Conversation

rmadurawe13
Copy link
Contributor

The following bugs were detected when doing further testing (both in the pre-previous bug fix code and post-previous bug fix code):

  • When internet is no longer available while WiFi is still connected and then internet comes back on, ESP32 cannot connect to Azure IoT Central server
  • When internet goes off during inital provisioning stage, Azure IoT Central Operation ID becomes corrupted
  • When WiFi is restarted without internet connectivity, ESP32 gets stuck in an infinite Azure IoT connection loop which leads to memory exhaust

When the ESP32 disconnects from WiFi and then reconnects, it gets stuck in an infinite azure reconnecting loop
The bug fix that was previously applied to the Azure_IoT_Central_ESP32.ino file where the connecting process to Azure IoT Central gets stuck in an infinite connecting-disconnecting loop after the WiFi is restarted, has now been applied to the Azure_IoT_Central_ESP32_AzureIoTKit.ino example file.
The following bugs were detected when doing further testing (both in the pre-previous bug fix code and post-previous bug fix code):
- When internet is no longer available while WiFi is still connected and then internet comes back on, ESP32 cannot connect to Azure IoT Central server
- When internet goes off during inital provisioning stage, Azure IoT Central Operation ID becomes corrupted
- When WiFi is restarted without internet connectivity, ESP32 gets stuck in an infinite Azure IoT connection loop which leads to memory exhaust
@rmadurawe13
Copy link
Contributor Author

Hi @danewalton. Just FYI, this is another bug I came accross while working on my project. If you could check it out whenever you've got some free time, I'm sure this would benifit others also

@@ -406,14 +411,22 @@ void loop()
{
if (WiFi.status() != WL_CONNECTED)
{
azure_iot_stop(&azure_iot);
if (azure_iot.state != azure_iot_state_not_initialized)
azure_iot_stop(&azure_iot);
Copy link
Contributor

Choose a reason for hiding this comment

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

Within azure_iot_stop the first check is if azure_iot->state == azure_iot_state_not_initialized.
If azure_iot is azure_iot_state_not_initialized, nothing is done by azure_iot_stop.
So the only reason to check here again is to avoid printing error logs? Remember that this is a sample, so for a production scenario customers can just remove the logging from azure_iot_stop.

connect_to_wifi();

if (!azure_initial_connect)
Copy link
Contributor

Choose a reason for hiding this comment

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

Now these two are more serious. This is probably coming because there is possible data corruption when there is wifi disconnection. This seems plausible. We will run a few more tests here.

case azure_iot_disconnected:
azure_iot_start(&azure_iot);
WiFi.disconnect();
Copy link
Contributor

Choose a reason for hiding this comment

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

So here this is more aggressive trying to re-establish connection with Azure IoT Hub. It is a more guaranteed way of doing so, but also more costly (due to a full internet reconnection).
We can do it that way, it will make the sample more reliable, I believe. Remembering that this is just a sample, not production code.

@ewertons
Copy link
Contributor

Code changes merged through PR #56

@ewertons ewertons closed this Jun 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants