Code Monkey home page Code Monkey logo

Comments (9)

olivierbloch avatar olivierbloch commented on July 20, 2024

Hi @bartoszbr
There are 2 topics here. The first one is the retry/reconnect logic, the second is the ping delays between service and device.

Let me first answer to the keep alive delays:
All Azure services are bound to the Azure load balancer TCP Idle time out which is 4 min (as of today), which means that the Azure load balancer will tear down any TCP connection to any service if no traffic has happened in the last 4 minutes. In order to ensure a Device/IoT Hub service connection stays alive (not that this applies only for MQTT or AMQP protocols, not for HTTP) both the service and the device client regularly send a "keep alive" or ping message: the service will ping the device before the 4 minutes timeout. The device client (our SDK) will send a keep alive (empty frame) every 2 minutes.
Few notes on the keep alive delays::

  • The keep alive mechanism is implemented only on the device client side of things, not on the service client side..
  • There are changes arriving soon to the Azure load balancer idle timeout that will impact these timings (will increase them). Stay tuned as we will make changes to the clients as soon as possible to minimize traffic still maintaining the connection alive between client and service.

Regarding the retry/reconnect logic:
We are in the process of implementing retry /reconnect policies across all our device SDKs. Once this implementation is done across all SDKs we will document them. The principle is to offer a set of configurable retry policies that the user can choose from depending on the best logic for his scenario.

It seems you have done tests on the service client side of things. In the service client, the feedback receiver mechanism will keep on retrying to establish the connection to the service until a Fatal exception occurs. You can see the implementation here: https://github.com/Azure/azure-iot-sdk-csharp/blob/master/service/Microsoft.Azure.Devices/AmqpFeedbackReceiver.cs

from azure-iot-sdk-csharp.

mathisharp avatar mathisharp commented on July 20, 2024

Hello,
I have issue with devicelostlockexception. I need to understand when this exception will be raised and also whether the connection will reestablish by itself and about the data send during that time will be rejected or will the abandoned message will be re-en-queued. My scenario is like sending 200k tags @ 10s collection rate 20k per second. So during this run we get devicelostlockexception. My concern is whenever this error raises whether the failed message is being re-enqueued or not.

from azure-iot-sdk-csharp.

20100g avatar 20100g commented on July 20, 2024

Hi @olivierbloch,

Do you have an idea when we can expect the changes to the Azure load balancer TCP idle timeout to be made available ? Also, can we expect to be able to configure the timeout for the IoT Hub public IP addresses up to 30 minutes just like in the Basic Azure Load Balancer (https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-tcp-idle-timeout) ?

from azure-iot-sdk-csharp.

anhashia avatar anhashia commented on July 20, 2024

Hi @bloodwine
Azure IoT Hub service has already been updated to use load balancer with timeout as 30 minutes.
For MQTT, the max on service side in 10 minutes currently. So you can set something like in C# application to set client side timeout to 6 minutes. MQTT server will set 6 x 1.5 = 9 minutes on server side

    var connectionString = DeviceConnectionString;
                var settings = new ITransportSettings[]
                {
                        new MqttTransportSettings(TransportType.Mqtt_Tcp_Only)
                        {
                        KeepAliveInSeconds = 360,
                        }
                };

For AMQP, max on service side is 25 minutes but you will have to open ticket with Azure support to increase the limit on your HUB. Please note that there is also a client side SDK change needed configure the service side ping for AMQP as shown in example below to reduce the service side pings.

https://github.com/Azure/azure-iot-sdk-c/blob/master/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp.c#L181

This option is currently only available in C SDK. For other SDK's, it is work in progress.

from azure-iot-sdk-csharp.

anhashia avatar anhashia commented on July 20, 2024

Similar to Azure/azure-iot-sdk-java#10

from azure-iot-sdk-csharp.

rgacuity avatar rgacuity commented on July 20, 2024

Hi @olivierbloch,
You mentioned above that

The device client (our SDK) will send a keep alive (empty frame) every 2 minutes.

We are using the "LL" API of the C SDK with AMQP on a Windows 10 device, and find that after several minutes of inactivity, the connection to the Hub is dropped (with a socket failure error 10054). When using the LL API, does our app itself need to periodically ping the Hub to keep the connection alive?

from azure-iot-sdk-csharp.

yzhong94 avatar yzhong94 commented on July 20, 2024

@jspaith @jebrando Can you clarify the question above?

from azure-iot-sdk-csharp.

olivierbloch avatar olivierbloch commented on July 20, 2024

Hi @rgacuity
can you please post this issue on the C SDK repo so that we can keep track of it in the right place?
Thanks

from azure-iot-sdk-csharp.

rgacuity avatar rgacuity commented on July 20, 2024

OK, have done so at Azure/azure-iot-sdk-c#499

from azure-iot-sdk-csharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.