Azure IoT失败访问[401未经授权]

时间:2019-01-14 16:12:48

标签: azure raspberry-pi azure-iot-hub

由于未经授权的访问,我面临从IoT Edge设备到其IoT Hub的连接问题(显然)。在个人(常规路由器-ISP)网络连接下,该相同设置可以正常工作,但是一旦在更大,更安全的网络中进行设置,则该设置将失败。

我确保为设备的静态IP打开了所有必需的端口,并且连接字符串没有错字,但问题仍然存在。经过研究,我发现一些有类似问题的用户在SAS身份验证方面遇到了麻烦,尽管我从未更改过它,也没有在之前进行的任何测试中摸过它,所以我不妨使用它。我遇到的错误日志如下:

-- Logs begin at Thu 2016-11-03 14:16:42 -03, end at Sun 2019-01-13 03:36:22 -03. --
Jan 13 03:05:21 camaraIQF0 systemd[1]: Started Azure IoT Edge daemon.
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Starting Azure IoT Edge Security Daemon
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Version - 1.0.5 (d76e0316c6f324345d77c48a83ce836d09392699)
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Using config file: /etc/iotedge/config.yaml
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Using runtime network id azure-iot-edge
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Initializing the module runtime...
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Initializing module runtime...
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Successfully initialized module runtime
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Finished initializing the module runtime.
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Configuring /var/lib/iotedge as the home directory.
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Configuring certificates...
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Transparent gateway certificates not found, operating in quick start mode...
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Finished configuring certificates.
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Initializing hsm...
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Finished initializing hsm.
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Detecting if configuration file has changed...
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - No change to configuration file detected.
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Obtaining workload CA succeeded.
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Provisioning edge device...
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Manually provisioning device "camaraIQF_0" in hub "camarasIQF.azure-devices.net"
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Finished provisioning edge device.
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Starting management API...
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Starting workload API...
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Starting watchdog with 60 second frequency...
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Listening on fd://iotedge.mgmt.socket/ with 1 thread for management API.
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Listening on fd://iotedge.socket/ with 1 thread for workload API.
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Checking edge runtime status
Jan 13 03:05:21 camaraIQF0 iotedged[724]: 2019-01-13T06:05:21Z [INFO] - Creating and starting edge runtime module edgeAgent
Jan 13 03:05:22 camaraIQF0 iotedged[724]: 2019-01-13T06:05:22Z [WARN] - Error in watchdog when checking for edge runtime status:
Jan 13 03:05:22 camaraIQF0 iotedged[724]: 2019-01-13T06:05:22Z [WARN] - A module runtime error occurred.
Jan 13 03:05:22 camaraIQF0 iotedged[724]: 2019-01-13T06:05:22Z [WARN] -         caused by: Could not get identity $edgeAgent
Jan 13 03:05:22 camaraIQF0 iotedged[724]: 2019-01-13T06:05:22Z [WARN] -         caused by: Could not get module $edgeAgent
Jan 13 03:05:22 camaraIQF0 iotedged[724]: 2019-01-13T06:05:22Z [WARN] -         caused by: HTTP request failed: [401 Unauthorized] {"Message":"ErrorCode:IotHubUnauthorizedAccess;Un         authorized","ExceptionMessage":"Tracking ID:876068fddc8545f799e54da7f991d694-G:10-TimeStamp:01/14/2019 15:19:50"}

在最后一条警告消息之后,它会不断循环检查边缘运行时状态和连接失败,因此它从不下载模块,因此无法正常运行。该设备是运行树莓派的树莓派。

关于这个问题有什么想法吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

发现了问题,如果有人遇到相同的问题,请在此处发布。

该设备无法自动获取日期和时间,因此该设备与Azure的日期和时间不匹配,从而导致了身份验证错误。

将树莓的日期和时间设置为我所在地区的当前日期和时间即可解决此问题。