I am investigating using MQTT (or AMQP) over a satellite connection. I am using MQTT over HTTPS towards an IoT Hub in Azure. Data is very expensive on satellite and I am trying to minimize the "idle" consumption of this connection. I can do this by changing how often the SaS token is renewed (default 1 hour) and the Keep Alive.
I am using the DeviceClient from the Microsoft.Azure.Devices NuGet package and there I can create a TransportSettings object and set the keep alive:
ITransportSettings transportSettings = new MqttTransportSettings(TransportType.Mqtt_WebSocket_Only)
{
KeepAliveInSeconds = 90,
};
I then create the connection like this:
var client = DeviceClient.CreateFromConnectionString(connectionString , new[] { transportSettings });
What I experience is. If I omit the transport settings, the connections sends a keep alive every 5 seconds. If I set the keep alive to anything from 30 and above, it always sends the keep alive every 30 seconds. The description of the KeepAliveInSeconds property tells the default is 300 seconds:
But my Wireshark trace tells a different story:
When no MqttTransportSettings are given in the CreateFromConnectionString then it sends a keep alive every 5 seconds. When i add the settings, I can set the keep alive to 10 or 30 seocnds and this works, but if I set it to 90 like this example, it stays on the 30 seconds ()or so the Wireshark trace show). I tried to look in Azure if I can change anything there. And there are no settings like this on the IoT Hub.
So hopefully someone else experienced this and found a solution, from the client side to have a keep alive that is not sent every 5 or 30 seconds. My goal is like once ever 2-5 minutes.