iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection. mqtt_client timed out waiting for CONNACK

青春壹個敷衍的年華 提交于 2019-12-13 20:10:02

问题


OS:Linux SDK Version : 2018-12-13 Description of the issue:

iothub_ll_telemetry_sample.c when i placed 60000 in the function ThreadAPI_Sleep(60000) works well but Tried with 120000 facing the timeout error.

cd ~/azure-iot-sdk-c/cmake/iothub_client/samples/iothub_ll_telemetry_sample $ ./iothub_ll_telemetry_sample

Console log of the issue:

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

Note: In previous version you said it's resolved but here it's not working form me. Please Explain me where is the problem.


回答1:


The "LL" version of SDK functions are single threaded. When modify the code to sleep for two minutes the SDK is unable to service the socket and hence does not receive the CONNACK packet in time. The function call that services the socket is IoTHubDeviceClient_LL_DoWork. This function should be called at a bare minimum every 100 ms and preferably more quickly than that. If you only want to send a message every two minutes the onus is upon you to keep track of the time and send your message every time it has been two minutes since your last message. You cannot simply put the thread to sleep for two minutes.



来源:https://stackoverflow.com/questions/53880311/iothub-client-src-iothubtransport-mqtt-common-c-funcinitializeconnection-mqtt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!