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

retry longhaul Device Method due to SAS refresh #1794

Merged
merged 4 commits into from
Dec 15, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1388,15 +1388,27 @@ static int invoke_device_method(const void* context)
device_method_info.method_id = method_id;
device_method_info.time_invoked = time(NULL);

if ((device_method_info.method_result = IoTHubDeviceMethod_Invoke(
iotHubLonghaul->iotHubSvcDevMethodHandle,
iotHubLonghaul->deviceInfo->deviceId,
LONGHAUL_DEVICE_METHOD_NAME,
message,
MAX_DEVICE_METHOD_TRAVEL_TIME_SECS,
&responseStatus, &responsePayload, &responseSize)) != IOTHUB_DEVICE_METHOD_OK)
for (int i = 0; i < 2; i++)
{
LogError("Failed invoking device method");
device_method_info.method_result = IoTHubDeviceMethod_Invoke(
iotHubLonghaul->iotHubSvcDevMethodHandle,
iotHubLonghaul->deviceInfo->deviceId,
LONGHAUL_DEVICE_METHOD_NAME,
message,
MAX_DEVICE_METHOD_TRAVEL_TIME_SECS,
&responseStatus, &responsePayload, &responseSize);

if (device_method_info.method_result == IOTHUB_DEVICE_METHOD_OK || responseStatus != 404)
{
break;
}

ThreadAPI_Sleep(1000 * 60); // wait for the SAS reconnect and try again
}

if (device_method_info.method_result != IOTHUB_DEVICE_METHOD_OK)
{
LogError("Failed invoking device method with status %d", responseStatus);
}

if (iothub_client_statistics_add_device_method_info(iotHubLonghaul->iotHubClientStats, DEVICE_METHOD_INVOKED, &device_method_info) != 0)
Expand Down