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

[Technical Question] [SDK v2] Lack of timeout options for IoT Hub device client #3332

Closed
bastyuchenko opened this issue May 15, 2023 · 6 comments
Assignees
Labels
IoTSDK Tracks all IoT SDK issues across the board question Further information is requested. v2 This issue is relevant or will only be addressed in v2.0.0+

Comments

@bastyuchenko
Copy link

bastyuchenko commented May 15, 2023

Hello,
I see that only IdleTimeout available for IotHubClientMqttSettings and ProvisioningClientMqttSettings. Maybe I'm wrong but it seems other timeouts are hardcoded or not implemented.
For example, Azure IoT SDK for C has OPTION_MESSAGE_TIMEOUT, OPTION_CONNECTION_TIMEOUT.
https://github.com/Azure/azure-iot-sdk-c/blob/main/doc/connection_and_messaging_reliability.md

Is there any way in Azure IoT SDK .NET v2 to configure similar parameters?

@bastyuchenko bastyuchenko added the question Further information is requested. label May 15, 2023
@github-actions github-actions bot added the IoTSDK Tracks all IoT SDK issues across the board label May 15, 2023
@abhipsaMisra abhipsaMisra added the v2 This issue is relevant or will only be addressed in v2.0.0+ label May 15, 2023
@patilsnr
Copy link
Contributor

patilsnr commented Aug 1, 2023

Hey @bastyuchenko - you're right in that many timeouts in the .NET SDK are private fields that are set internally and thus cannot be modified like in the C SDK. Are there specific timeouts that you're working with that you'd like to be able to tweak, or is this more of just a general wondering about how they work in .NET?

@patilsnr
Copy link
Contributor

patilsnr commented Aug 3, 2023

Closing this issue for now, feel free to reopen it should the desire arise.

@patilsnr patilsnr closed this as completed Aug 3, 2023
@bastyuchenko
Copy link
Author

bastyuchenko commented Aug 10, 2023

Hi @patilsnr
Sorry for the time I took to reply to you, I was on vacation. Could you reopen this Tech Question?

Our customer is going to increase number of devices in a fleet and I'm implementing a performance test to understand how various options affect communication in our specific scenarios. After the perf testing is finished, I'm going to tweak the most suitable values of these options in PROD env.

I use MQTT protocol in our solution.
There are specific timeouts that I'm working with:

  • OPTION_CONNECTION_TIMEOUT (IoTHubDeviceClient_SetOption) - While connecting, it is the maximum number of seconds the device client (when using MQTT) will wait for the connection to complete (CONNACK).
  • PROV_OPTION_TIMEOUT (Prov_Device_LL_SetOption) - Maximum time to allow DPS to complete, in seconds.
  • OPTION_KEEP_ALIVE (IoTHubClient_SetOption) - Frequency in seconds that the transport protocol will be sending MQTT pings to the Azure IoT Hub. Maybe keep_alive option was implemented through IotHubClientMqttSettings.IdleTimeout in .NET SDK, please confirm.
  • OPTION_MESSAGE_TIMEOUT (IoTHubClient_SetOption) - Timeout for iothub client messages waiting to be sent to the IoTHub.

@patilsnr patilsnr reopened this Aug 10, 2023
@patilsnr
Copy link
Contributor

patilsnr commented Aug 10, 2023

Hi @bastyuchenko. I have confirmed that OPTION_KEEP_ALIVE is implemented via IdleTimeout for MQTT connections. The others seem to be set internally, and I can find out where the .NET equivalents of them happen. Configuring these constants would have to be done through modifying the source code directly in this case, unlike in the C SDK.

@patilsnr
Copy link
Contributor

Hi again @bastyuchenko. I've looked into it and it seems that these timeouts are internally handled through .NET's [IMqttClient](https://github.com/dotnet/MQTTnet/wiki/Client) and MqttClientOptions classes, for example:

image

These clients are used by the SDK in the MqttTransportHandler and ProvisioningMqttTransportHandler classes and are internal fields. I will keep looking and update you if I'm mistaken, but it seems that the .NET SDk is not as modular for upating timeouts as the C SDK is, and the best way to do so would be by forking off of GitHub and playing with where we define the IMqttClient in our transport handler files. I hope this helps, and please let us know if you have any questions.

@andyk-ms
Copy link
Contributor

Provided suggestion and work around on source given the limitation on the current version of the SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IoTSDK Tracks all IoT SDK issues across the board question Further information is requested. v2 This issue is relevant or will only be addressed in v2.0.0+
Projects
None yet
Development

No branches or pull requests

4 participants