espressif / esp-azure

SDK to connect ESP8266 and ESP32 to Microsoft Azure IoT services
176 stars 92 forks source link

Not able to auto-reconnect with Azure Cloud (CA-218) #126

Open harshalbhav opened 2 years ago

harshalbhav commented 2 years ago

Environment

Problem Description

We have developed one hardware based on ESP32. We are using Azue-SDK for same development. We enabled debug flag for Azure-SDK so we are receiving all debug logs on console.

Right now we are facing issue with Azure-SDK. We have received disconnect event from Azure stack. As per the Azure stack we are expecting following points in this scenario.

Azure cloud should be update the device status like Device is disconnected. Device should be reconnect to the Azure cloud automatically. We are not able to full fill above both points. So, our Device and Azure cloud not able to get into valid state.

Please update us how to drive this thing.

Thanks, Harshal

Expected Behavior

Azure cloud should be update the device status like Device is disconnected. Device should be reconnect to the Azure cloud automatically. Confirmation[346] received for message tracking id = 346 with result = IOTHUB_CLIENT_CONFIRMATION_OK -> 06:26:46 DISCONNECT Connection Status result: IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, Connection Status reason: IOTHUB_CLIENT_CONNECTION_EXPIRED_SAS_TOKEN

*** SAS TOKEN EXPIRE RECEIVED **

-> 06:26:49 CONNECT | VER: 4 | KEEPALIVE: 240 | FLAGS: 192 | USERNAME: .... | PWD: XXXX | CLEAN: 0

<- 06:26:49 CONNACK | SESSION_PRESENT: true | RETURN_CODE: 0x0

Actual Behavior

Azure cloud not getting Device status as its disconnected. Device is not able to reconnect with Azure cloud. (We had wait till 5 to 8 min) Confirmation[346] received for message tracking id = 346 with result = IOTHUB_CLIENT_CONFIRMATION_OK -> 06:26:46 DISCONNECT Connection Status result: IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, Connection Status reason: IOTHUB_CLIENT_CONNECTION_EXPIRED_SAS_TOKEN

*** SAS TOKEN EXPIRE RECEIVED ** . . .

Steps to reproduce

No any particular step we observed.

zafarpatel7 commented 2 years ago

Hello @harshalbhav

I am also facing the same issue, in 24 hr 3-5 times I am getting the same issues, once I get this kind of error I am doing soft-reset which is not good looks to me

Hello Team Espressif Systems

Could you please help us with this issue

zafarpatel7 commented 2 years ago

@mahavirj could u plz help me on this

lhespress commented 2 years ago

@zafarpatel7 Please provide the example when you face the issue firstly and then check that the work thread is exit or not. such as : iothub_client_sample_mqtt has gotten quit message show on https://github.com/espressif/esp-azure/blob/master/examples/iothub_client_sample_mqtt/main/iothub_client_sample_mqtt.c#L229

harshalbhav commented 2 years ago

@lhespress Thanks for update. We are not receiving any thread exit message as you mentioned into the link. Also we have take care DoWork function call. In my case all debug logs are enabled.

We had used same sample code [iothub_client_sample_mqtt].

Thanks, Harshal

harshalbhav commented 2 years ago

@lhespress Thanks for update. We are not receiving any thread exit message as you mentioned into the link. Also we have take care DoWork function call. In my case all debug logs are enabled.

We had used same sample code [iothub_client_sample_mqtt].

Thanks, Harshal

zafarpatel7 commented 2 years ago

Hello All can anyone help us on this issue?

@mahavirj @shahpiyushv @wujiangang @jitin17