Closed Morozov-5F closed 5 years ago
In your log I am unable to see the CONNECT packet being sent from the device to the service. I see a few PUBLISH packets being sent and received. Can you resend a log with the connect packets included, it will give us a clue as to what's happening. The connect package should look similar to the following:
->XX:XX:XX CONNECT | VER: 4 | KEEPALIVE: 240 | FLAGS: 192 | USERNAME: XXX ...
@jebrando
In your log I am unable to see the CONNECT packet being sent from the device to the service.
The problem is that with our current logging configuration we don't see CONNECT packet in log. We use xlogging_set_log_function() to setup logging. Is it right way to configure IoT SDK logging?
I am not sure if it is useful but when SDK could normally connect we see following log entry with CONNACK
mqtt_client.c:297: iot_sdk_log_incoming_trace: <- 16:46:39 CONNACK | SESSION_PRESENT: true | RETURN_CODE: 0x0
As you see above there is no such message when issue happens.
This code snippet (which you have used in reporting #652) would help spew those out -
// Turn on Log
bool trace = true;
(void)IoTHubClient_SetOption(iotHubClientHandle, "logtrace", &trace);
@massand
This code snippet (which you have used in reporting #652) would help spew those out
We already use this option. But don't see CONNECT packet. Only CONNACK.
@Morozov-5F With MQTT the CONNECT packet is how it connects to the service. Without this message there is no CONNACK. We see the CONNACK so there must be a CONNECT packet. Finding that CONNECT packet will help in finding the callback. Is it consistent with the same logging, does the CONNECT never show up?
@jebrando I'm not sure about it, but I don't recall seeing that packet in our logs. I'll review logs and try different logging, then I'll let you know.
Hi @Morozov-5F Following up on this issue, I used a telemetry sample with MQTT protocol to verify. With network disconnected and after it is restored, I see callbacks as expected. Feel free to reopen the issue if the issue still exist and you have more questions. Also, these are my logs with highlighted callbacks, CONNECT , CONNACK, PUBLISH and PUBACK below:
Creating IoTHub Device handle Sending message 1 to IoTHub Error: Time:Wed Feb 6 14:19:03 2019 File:D:\iot\azure-iot-sdk-c\c-utility\adapters\socketio_win32.c Func:_lookup_address_and_initiate_socket_connection Line:299 Failure: getaddrinfo failure 11001. Error: Time:Wed Feb 6 14:19:03 2019 File:D:\iot\azure-iot-sdk-c\c-utility\adapters\socketio_win32.c Func:_socketio_open Line:390 lookup_address_and_connect_socket failed The device client has been disconnected CONNECTION STATUS REPORTED (result=IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED; reason=IOTHUB_CLIENT_CONNECTION_NO_NETWORK)Error: Time:Wed Feb 6 14:19:03 2019 File:D:\iot\azure-iot-sdk-c\c-utility\adapters\tlsio_schannel.c Func:_tlsio_schannel_open Line:1248 xio_open failed Error: Time:Wed Feb 6 14:19:03 2019 File:D:\iot\azure-iot-sdk-c\umqtt\src\mqtt_client.c Func:_mqtt_client_connect Line:1001 Error: io_open failed Error: Time:Wed Feb 6 14:19:03 2019 File:D:\iot\azure-iot-sdk-c\iothub_client\src\iothubtransport_mqtt_common.c Func:_SendMqttConnectMsg Line:2261 failure connecting to address TestHub.azure-devices.net. Error: Time:Wed Feb 6 14:19:04 2019 File:D:\iot\azure-iot-sdk-c\c-utility\adapters\socketio_win32.c Func:_lookup_address_and_initiate_socket_connection Line:299 Failure: getaddrinfo failure 11001. Error: Time:Wed Feb 6 14:19:04 2019 File:D:\iot\azure-iot-sdk-c\c-utility\adapters\socketio_win32.c Func:_socketio_open Line:390 lookup_address_and_connect_socket failed The device client has been disconnected CONNECTION STATUS REPORTED (result=IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED; reason=IOTHUB_CLIENT_CONNECTION_NO_NETWORK)Error: Time:Wed Feb 6 14:19:04 2019 File:D:\iot\azure-iot-sdk-c\c-utility\adapters\tlsio_schannel.c Func:_tlsio_schannel_open Line:1248 xio_open failed Error: Time:Wed Feb 6 14:19:04 2019 File:D:\iot\azure-iot-sdk-c\umqtt\src\mqtt_client.c Func:_mqtt_client_connect Line:1001 Error: io_open failed Error: Time:Wed Feb 6 14:19:04 2019 File:D:\iot\azure-iot-sdk-c\iothub_client\src\iothubtransport_mqtt_common.c Func:_SendMqttConnectMsg Line:2261 failure connecting to address TestHub.azure-devices.net. Error: Time:Wed Feb 6 14:19:06 2019 File:D:\iot\azure-iot-sdk-c\c-utility\adapters\socketio_win32.c Func:_lookup_address_and_initiate_socket_connection Line:299 Failure: getaddrinfo failure 11001. Error: Time:Wed Feb 6 14:19:06 2019 File:D:\iot\azure-iot-sdk-c\c-utility\adapters\socketio_win32.c Func:_socketio_open Line:390 lookup_address_and_connect_socket failed The device client has been disconnected CONNECTION STATUS REPORTED (result=IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED; reason=IOTHUB_CLIENT_CONNECTION_NO_NETWORK) Error: Time:Wed Feb 6 14:19:06 2019 File:D:\iot\azure-iot-sdk-c\c-utility\adapters\tlsio_schannel.c Func:_tlsio_schannel_open Line:1248 xio_open failed Error: Time:Wed Feb 6 14:19:06 2019 File:D:\iot\azure-iot-sdk-c\umqtt\src\mqtt_client.c Func:_mqtt_client_connect Line:1001 Error: io_open failed Error: Time:Wed Feb 6 14:19:06 2019 File:D:\iot\azure-iot-sdk-c\iothub_client\src\iothubtransport_mqtt_common.c Func:_SendMqttConnectMsg Line:2261 failure connecting to address TestHub.azure-devices.net. -> 14:19:12 CONNECT | VER: 4 | KEEPALIVE: 240 | FLAGS: 192 | USERNAME: TestHub.azure-devices.net/test_dev1/?api-version=2017-11-08-preview&DeviceClientType=iothubclient%* PWD: XXXX | CLEAN: 0 <- 14:19:12 CONNACK | SESSION_PRESENT: false | RETURN_CODE: 0x0 The device client is connected to iothub CONNECTION STATUS REPORTED (result=IOTHUB_CLIENT_CONNECTION_AUTHENTICATED; reason=IOTHUB_CLIENT_CONNECTION_OK) -> 14:19:12 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_LEAST_ONCE | TOPIC_NAME: devices/test_dev1/messages/events/property_key=property_value | PACKET_ID: 2 | PAYLOAD_LEN: 12 <- 14:19:12 PUBACK | PACKET_ID: 2 Confirmation callback received for message 1 with result IOTHUB_CLIENT_CONFIRMATION_OK Sending message 2 to IoTHub -> 14:19:16 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_LEAST_ONCE | TOPIC_NAME: devices/test_dev1/messages/events/property_key=property_value | PACKET_ID: 3 | PAYLOAD_LEN: 12 <- 14:19:16 PUBACK** | PACKET_ID: 3 Confirmation callback received for message 2 with result IOTHUB_CLIENT_CONFIRMATION_OK
@jebrando, @vladimir-didenko, @massand, @Morozov-5F, @bikamani, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey
OS and version used: MIPS Linux OpenWrt 3.18.29
SDK version used: IoT Hub SDK for C, version 1.2.9 (2018-09-11)
Description of the issue:
After device startup, Wi-Fi is not available yet and IoT SDK reports connection status as OFFLINE (NO NETWORK). After a while, the connection is restored and SDK logs communication with IoT Hub, but connection callback is never called with status ONLINE.
Code sample exhibiting the issue:
This is a extensive modified x509 sample. Sample code is available here: azure.c.
Console log of the issue: