安全隧道功能的例程运行后,您可以在设备端查看相关日志。
前提条件
已配置C Link SDK的安全隧道功能例程,详细信息,请参见使用示例。
设备端日志
连接日志:
[1631513133.788][LK-0313] MQTT user calls aiot_mqtt_connect api, connect [1631513133.788][LK-0317] LightSwitch&a18wP****** [1631513133.788][LK-0318] 8B6DE4C174E205DCA3084C3D1C325E6CF580C1442F2F4EA516307486C78****** establish tcp connection with server(host='iot-06******.mqtt.iothub.aliyuncs.com', port=[443]) success to establish tcp, fd=3 local port: 50612 [1631513133.844][LK-1000] establish mbedtls connection with server(host='iot-06******.mqtt.iothub.aliyuncs.com', port=[443]) [1631513133.922][LK-1000] success to establish mbedtls connection, (cost 44947 bytes in total, max used 47859 bytes) [1631513133.922][LK-0319] a18wP******.LightSwitch|timestamp=2524608000000,_ss=1,_v=sdk-c-4.1.0,securemode=2,signmethod=hmacsha256,ext=3,_conn=tls_8e,cid=1| [1631513133.977][LK-0313] MQTT connect success in 194 ms AIOT_MQTTEVT_CONNECT
开启安全隧道日志:
以下日志显示:设备通知物联网平台,设备端已具备安全隧道功能。[1631513133.977][LK-0317] cid[1] connected, online channel 1 [1631513133.977][LK-0309] sub: /sys/a18wP******/LightSwitch/secure_tunnel/notify [1631513133.977][LK-1C00] remote proxy thread start! heartbeat response suback, res: -0x0000, packet id: 1, max qos: 1
创建安全隧道日志:
物联网平台创建安全隧道后,设备端接收如下消息日志。
[1632377338.388][LK-0309] pub: /sys/a18wP******/LightSwitch/secure_tunnel/notify [LK-030A] < 7B 22 73 63 68 65 6D 61 22 3A 22 77 73 73 22 2C | {"schema":"wss", [LK-030A] < 22 70 61 74 68 22 3A 22 2F 74 75 6E 6E 65 6C 2F | "path":"/tunnel/ [LK-030A] < 34 39 63 36 65 62 63 64 2D 63 30 31 37 2D 34 33 | 49c6ebcd-c017-43 [LK-030A] < 62 30 2D 38 31 35 34 2D 37 37 38 35 39 62 30 34 | b0-8154-77859b** [LK-030A] < 66 32 30 36 2F 64 65 73 74 22 2C 22 74 75 6E 6E | ****/dest","tunn [LK-030A] < 65 6C 5F 69 64 22 3A 22 34 39 63 36 65 62 63 64 | el_id":"49c6ebcd [LK-030A] < 2D 63 30 31 37 2D 34 33 62 30 2D 38 31 35 34 2D | -c017-43b0-8154- [LK-030A] < 37 37 38 35 39 62 30 34 66 32 30 36 22 2C 22 70 | 7785******","p [LK-030A] < 61 79 6C 6F 61 64 5F 6D 6F 64 65 22 3A 22 72 65 | ayload_mode":"re [LK-030A] < 6C 61 79 22 2C 22 70 6F 72 74 22 3A 34 34 33 2C | lay","port":443, [LK-030A] < 22 68 6F 73 74 22 3A 22 69 6F 74 2D 73 65 63 75 | "host":"iot-secu [LK-030A] < 72 65 2D 74 75 6E 6E 65 6C 2D 68 7A 2D 70 72 65 | re-tunnel-**-*** [LK-030A] < 2E 61 6C 69 79 75 6E 63 73 2E 63 6F 6D 22 2C 22 | .aliyuncs.com"," [LK-030A] < 6F 70 65 72 61 74 69 6F 6E 22 3A 22 63 6F 6E 6E | operation":"conn [LK-030A] < 65 63 74 22 2C 22 75 72 69 22 3A 22 77 73 73 3A | ect","uri":"wss: [LK-030A] < 2F 2F 69 6F 74 2D 73 65 63 75 72 65 2D 74 75 6E | //iot-secure-tun [LK-030A] < 6E 65 6C 2D 68 7A 2D 70 72 65 2E 61 6C 69 79 75 | nel-******.aliyu [LK-030A] < 6E 63 73 2E 63 6F 6D 2F 74 75 6E 6E 65 6C 2F 34 | ncs.com/tunnel/4 [LK-030A] < 39 63 36 65 62 63 64 2D 63 30 31 37 2D 34 33 62 | 9c6ebcd-c017-43b [LK-030A] < 30 2D 38 31 35 34 2D 37 37 38 35 39 62 30 34 66 | 0-8154-77859b*** [LK-030A] < 32 30 36 2F 64 65 73 74 22 2C 22 74 6F 6B 65 6E | ***/dest","token [LK-030A] < 22 3A 22 37 37 65 32 38 33 38 66 2D 31 33 30 38 | ":"77e2838f-1308 [LK-030A] < 2D 34 30 32 64 2D 39 34 39 35 2D 38 34 39 63 38 | -402d-9495-849c8 [LK-030A] < 63 32 35 63 36 36 36 22 7D | c******"} [1632377338.388][LK-1C00] _switch_topic_handler payload:{"schema":"wss","path":"/tunnel/49c6ebcd-c017-43b0-8154-7785******/dest","tunnel_id":"49c6ebcd-c017-43b0-8154-7785******","payload_mode":"relay","port":443,"host":"iot-secure-tunnera_event_cb AIOT_RA_EVT_OPEN_WEBSOCKET 49c6ebcd-c017-43b0-8154-7785****** [1632377338.511][LK-1C00] start to create cloud channel [1632377338.511][LK-1C00] connect remote service host iot-secure-tunnel-******.aliyuncs.com, port 443establish tcp connection with server(host='iot-secure-tunnel-******.aliyuncs.com', port=[443]) success to establish tcp, fd=4 local port: 47000 [1632377338.588][LK-1000] establish mbedtls connection with server(host='iot-secure-tunnel-******.aliyuncs.com', port=[443]) [1632377338.644][LK-1000] success to establish mbedtls connection, (cost 55299 bytes in total, max used 57987 bytes) [1632377338.700][LK-0F10] open_cloud_proxy_channel success [1632377338.700][LK-1C00] websocket 49c6ebcd-c017-43b0-8154-7785****** opened ra_event_cb AIOT_RA_EVT_CONNECT 49c6ebcd-c017-43b0-8154-7785****** heartbeat response
后续步骤
运行日志中出现的错误信息,请参见aiot_ra_api.h,中的状态码描述根据提示解决问题。