longhaul: handle IoTHubDeviceTwin_GetTwin network error (#2189)
* handle IoTHubDeviceTwin_GetTwin network error * pr feedback
This commit is contained in:
Родитель
f71e817e75
Коммит
e3f6b264b7
|
@ -1675,11 +1675,20 @@ static void on_twin_report_state_completed(int status_code, void* userContextCal
|
|||
|
||||
static void check_for_reported_properties_update_on_service_side(IOTHUB_LONGHAUL_RESOURCES* iotHubLonghaul)
|
||||
{
|
||||
char* twin;
|
||||
char* twin = NULL;
|
||||
|
||||
if ((twin = IoTHubDeviceTwin_GetTwin(
|
||||
iotHubLonghaul->iotHubSvcDevTwinHandle,
|
||||
iotHubLonghaul->deviceInfo->deviceId)) == NULL)
|
||||
for (int i = 0; i < NETWORK_RETRY_ATTEMPTS && twin == NULL; i++)
|
||||
{
|
||||
twin = IoTHubDeviceTwin_GetTwin(iotHubLonghaul->iotHubSvcDevTwinHandle, iotHubLonghaul->deviceInfo->deviceId);
|
||||
if (twin == NULL)
|
||||
{
|
||||
// this API can fail due to network issues (ex: DNS issues)
|
||||
// try a few times before reporting an error
|
||||
ThreadAPI_Sleep(NETWORK_RETRY_DELAY_MSEC);
|
||||
}
|
||||
}
|
||||
|
||||
if (twin == NULL)
|
||||
{
|
||||
LogError("Failed getting the twin document on service side");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче