admin管理员组

文章数量:1123272

I'm trying to set up an Azure IotHub client with the C SDK, and I noticed that if I don't send out a new MQTT message every 10 seconds, the connection to the Hub is closed. I'd like to increase this timeout, and I think the option I need is "keepalive" (OPTION_KEEP_ALIVE, see this doc page). However, if I try to do

IOTHUB_DEVICE_CLIENT_LL_HANDLE device_ll_handle;
// [...]
int keepalive = 20;
IoTHubTransport_MQTT_Common_SetOption(device_ll_handle, OPTION_KEEP_ALIVE, &keepalive);
// [...]
device_ll_handle = IoTHubDeviceClient_LL_CreateFromConnectionString(connection_string, iothub_transport)

in the code opening the device handle, I end up with a SEGFAULT, because it detects the connection as already open, and it tries to disconnect with DisconnectFromClient(transport_data). I can't find in the doc how to set this option: where should I set it? Thanks!

本文标签: How can I set the MQTT keepalive in the Azure IoTHub C SDKStack Overflow