iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection。 mqtt_client 等待 CONNACK 超时
iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection. mqtt_client timed out waiting for CONNACK
OS:Linux
开发工具包版本:2018-12-13
问题描述:
iothub_ll_telemetry_sample.c
当我将 60000 放入函数 ThreadAPI_Sleep(60000) 时效果很好,但尝试使用 120000 时遇到超时错误。
cd ~/azure-iot-sdk-c/cmake/iothub_client/samples/iothub_ll_telemetry_sample
$ ./iothub_ll_telemetry_sample
问题的控制台日志:
Creating IoTHub Device handle
Sending message 1 to IoTHub
Sending message 2 to IoTHub
Error: Time:Fri Dec 21 11:12:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK
Sending message 3 to IoTHub
Sending message 4 to IoTHub
Error: Time:Fri Dec 21 11:16:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK
Sending message 5 to IoTHub
Error: Time:Fri Dec 21 11:18:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK
Error: Time:Fri Dec 21 11:20:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK
Error: Time:Fri Dec 21 11:22:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK
Error: Time:Fri Dec 21 11:24:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK
Error: Time:Fri Dec 21 11:26:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK
注意:
在以前的版本中,你说它已经解决了,但在这里它对我不起作用。请解释一下问题出在哪里。
"LL"版本的SDK函数是单线程的。当修改代码休眠两分钟时,SDK 无法为套接字提供服务,因此无法及时收到 CONNACK 数据包。为套接字提供服务的函数调用是 IoTHubDeviceClient_LL_DoWork
。这个函数应该至少每 100 毫秒调用一次,最好比这更快。如果您只想每两分钟发送一次消息,那么您有责任跟踪时间并在您上次发送消息后每两分钟发送一次消息。您不能简单地让线程休眠两分钟。
OS:Linux 开发工具包版本:2018-12-13 问题描述:
iothub_ll_telemetry_sample.c 当我将 60000 放入函数 ThreadAPI_Sleep(60000) 时效果很好,但尝试使用 120000 时遇到超时错误。
cd ~/azure-iot-sdk-c/cmake/iothub_client/samples/iothub_ll_telemetry_sample $ ./iothub_ll_telemetry_sample
问题的控制台日志:
Creating IoTHub Device handle Sending message 1 to IoTHub Sending message 2 to IoTHub Error: Time:Fri Dec 21 11:12:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Sending message 3 to IoTHub Sending message 4 to IoTHub Error: Time:Fri Dec 21 11:16:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Sending message 5 to IoTHub Error: Time:Fri Dec 21 11:18:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Error: Time:Fri Dec 21 11:20:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Error: Time:Fri Dec 21 11:22:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Error: Time:Fri Dec 21 11:24:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK Error: Time:Fri Dec 21 11:26:19 2018 File:/home/test/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2229 mqtt_client timed out waiting for CONNACK
注意: 在以前的版本中,你说它已经解决了,但在这里它对我不起作用。请解释一下问题出在哪里。
"LL"版本的SDK函数是单线程的。当修改代码休眠两分钟时,SDK 无法为套接字提供服务,因此无法及时收到 CONNACK 数据包。为套接字提供服务的函数调用是 IoTHubDeviceClient_LL_DoWork
。这个函数应该至少每 100 毫秒调用一次,最好比这更快。如果您只想每两分钟发送一次消息,那么您有责任跟踪时间并在您上次发送消息后每两分钟发送一次消息。您不能简单地让线程休眠两分钟。