运行日志

HTTPS接入功能的例程运行后,您可以在设备端和物联网平台查看日志信息。

前提条件

已配置C Link SDK的HTTPS接入功能例程,详细信息,请参见使用示例

设备端日志

您可以在设备端查看运行结果。

  • 连接日志:

    出现如下日志,表示设备与物联网平台连接成功。

    core_sysdep_network_establish host iot-as-http.cn-shanghai.aliyuncs.com port 443, type 0
    establish tcp connection with server(host='iot-as-http.cn-shanghai.aliyuncs.com', port=[443])
    success to establish tcp, fd=3
    local port: 56028
    [1621563692.299][LK-1000] establish mbedtls connection with server(host='iot-as-http.cn-shanghai.aliyuncs.com', port=[443])
    [1621563692.300][LK-1000] success to establish mbedtls connection, (cost 44722 bytes in total, max used 47410 bytes)
    [1621563692.300][LK-040B] > POST /auth?_v=sdk-c-4.1.0& HTTP/1.1
    [1621563692.300][LK-040B] > Host: iot-as-http.cn-shanghai.aliyuncs.com
    [1621563692.300][LK-040B] > Content-Type: application/json
    [1621563692.300][LK-040B] > Content-Length: 192
    [1621563692.300][LK-040B] >
    [LK-040C] > 7B 22 63 6C 69 65 6E 74  49 64 22 3A 22 61 31 77 | {"clientId":"a1w
    [LK-040C] > 41 66 49 55 6C 41 39 4E  2E 4C 69 67 68 74 53 77 | Af******.LightSw
    [LK-040C] > 69 74 63 68 22 2C 22 73  69 67 6E 6D 65 74 68 6F | itch","signmetho
    [LK-040C] > 64 22 3A 22 68 6D 61 63  73 68 61 32 35 36 22 2C | d":"hmacsha256",
    [LK-040C] > 22 64 65 76 69 63 65 4E  61 6D 65 22 3A 22 4C 69 | "deviceName":"Li
    [LK-040C] > 67 68 74 53 77 69 74 63  68 22 2C 22 70 72 6F 64 | ghtSwitch","prod
    [LK-040C] > 75 63 74 4B 65 79 22 3A  22 61 31 77 41 66 49 55 | uctKey":"a1wAf**
    [LK-040C] > 6C 41 39 4E 22 2C 22 73  69 67 6E 22 3A 22 41 36 | ****","sign":"A6
    [LK-040C] > 43 30 32 31 32 42 44 42  33 39 45 32 36 35 38 39 | C0212BDB39E26589
    [LK-040C] > 36 41 39 41 43 36 34 36  44 33 35 46 39 33 31 43 | 6A9AC646D35F931C
    [LK-040C] > 36 46 35 32 37 36 46 32  41 42 39 33 35 35 33 34 | 6F5276F2AB935534
    [LK-040C] > 30 37 42 31 46 45 33 39  43 31 33 35 37 46 22 7D | 07B1FE39******"}
    [1621563692.377][LK-040D] < HTTP/1.1 200
    [1621563692.377][LK-040D] < Server: nginx/1.14.2
    [1621563692.377][LK-040D] < Date: Fri, 21 May 2021 02:21:32 GMT
    [1621563692.377][LK-040D] < Content-Type: application/json
    [1621563692.377][LK-040D] < Content-Length: 82
    [1621563692.377][LK-040D] < Connection: keep-alive
    [1621563692.377][LK-040D] <
    [LK-040E] < 7B 22 63 6F 64 65 22 3A  30 2C 22 69 6E 66 6F 22 | {"code":0,"info"
    [LK-040E] < 3A 7B 22 74 6F 6B 65 6E  22 3A 22 5E 31 5E 31 36 | :{"token":"^1^16
    [LK-040E] < 32 31 35 36 33 36 39 32  33 36 34 5E 66 33 35 35 | 21563692364^f355
    [LK-040E] < 63 39 30 35 66 37 66 31  37 37 34 22 7D 2C 22 6D | c905f******"},"m
    [LK-040E] < 65 73 73 61 67 65 22 3A  22 73 75 63 63 65 73 73 | essage":"success
    [LK-040E] < 22 7D                                            | "}
    [1621563692.377][LK-0410] {"code":0,"info":{"token":"^1^1621563692364^f355c905f******"},"message":"success"}
    aiot_http_auth succeed
  • 上报消息日志:

    连接建立后,以下日志说明设备通过Topic,例如/a18wP******/LightSwitch/user/update,向物联网平台上报了一条消息。

    [1621563692.377][LK-040B] > POST /topic/a1wAf******/LightSwitch/user/update HTTP/1.1
    [1621563692.377][LK-040B] > Host: iot-as-http.cn-shanghai.aliyuncs.com
    [1621563692.377][LK-040B] > Content-Type: application/octet-stream
    [1621563692.377][LK-040B] > Password: ^1^1621563692364^f355c905f******
    [1621563692.377][LK-040B] > Content-Length: 53
    [1621563692.377][LK-040B] >
    [LK-040C] > 7B 22 69 64 22 3A 22 31  22 2C 22 76 65 72 73 69 | {"id":"1","versi
    [LK-040C] > 6F 6E 22 3A 22 31 2E 30  22 2C 22 70 61 72 61 6D | on":"1.0","param
    [LK-040C] > 73 22 3A 7B 22 4C 69 67  68 74 53 77 69 74 63 68 | s":{"LightSwitch
    [LK-040C] > 22 3A 30 7D 7D                                   | ":0}}
  • 响应日志:

    以下日志为物联网平台收到消息后,发回至设备的报文。

    [1621563692.477][LK-040D] < HTTP/1.1 200
    [1621563692.477][LK-040D] < Server: nginx/1.14.2
    [1621563692.477][LK-040D] < Date: Fri, 21 May 2021 02:21:32 GMT
    [1621563692.477][LK-040D] < Content-Type: application/json
    [1621563692.477][LK-040D] < Content-Length: 71
    [1621563692.477][LK-040D] < Connection: keep-alive
    [1621563692.477][LK-040D] <

物联网平台日志

您可以在物联网平台控制台查看设备的状态和运行日志。

  • 在线状态:

    在左侧导航栏,选择设备管理 > 设备,找到设备,查看设备状态。设备状态显示为在线,则表示设备与物联网平台成功连接。查看设备状态
  • 运行日志:

    在左侧导航栏,选择监控运维 > 日志服务,选择产品后,查看设备上线、订阅Topic和上报消息的日志。

    HTTP上报消息的日志

后续步骤

运行日志中出现的错误信息,请参见常见错误码,根据提示解决问题。