【发布时间】:2018-12-01 20:07:29
【问题描述】:
我的问题可能和this post 一样,但我不明白那些花哨的大城市stackoverflow 政治,所以我不想打扰任何人,只是问我自己的问题。
我想根据 Microsoft 教程here 将我的 Windows PC 作为“边缘设备”连接到我的 Azure IoT Hub。当我只运行作为 Microsoft 存储库中的图像的“温度传感器”模块时,一切正常。模块运行,连接到集线器容器,将数据发送到天蓝色集线器。
下一步是编写自定义模块。 Microsoft 网站上还有一个教程,它提供了 C# 和 Python 的模板,可以针对任何目的进行修改。我尝试了两个示例(C# 和 Python),但只有 C#-Version 没有任何进一步的问题。但由于我对 C# 不是很精通,只精通 Python,所以我也需要运行那个。
但 Python 版本在下载图像并启动容器后不久就失败了。 edgeAgent 和 edgeHub 以及模拟“温度传感器”模块像以前一样运行没有问题。但是自定义 python 模块似乎无法连接到集线器容器。 docker日志如下:
edgeAgent:
2018-06-22 10:28:26.062 +00:00 [INF] - Plan execution started for deployment 8
2018-06-22 10:28:26.062 +00:00 [INF] - Executing command: "Command Group: (
[docker stop -t 10 filterModule]
[docker start filterModule]
[Update health stats for module filterModule]
)"
2018-06-22 10:28:26.062 +00:00 [INF] - Executing command: "docker stop -t 10 filterModule"
2018-06-22 10:28:26.063 +00:00 [INF] - Executing command: "docker start filterModule"
2018-06-22 10:28:26.567 +00:00 [INF] - Executing command: "Update health stats for module filterModule"
2018-06-22 10:28:26.567 +00:00 [INF] - Plan execution ended for deployment 8
2018-06-22 10:28:26.872 +00:00 [INF] - Updated reported properties
2018-06-22 10:28:56.975 +00:00 [INF] - HealthRestartPlanner is clearing restart stats for module 'edgeHub' as it has been running healthy for 00:10:00.
2018-06-22 10:28:56.975 +00:00 [INF] - Plan execution started for deployment 8
2018-06-22 10:28:56.975 +00:00 [INF] - Executing command: "Reset health stats for module edgeHub"
2018-06-22 10:28:56.977 +00:00 [INF] - Plan execution ended for deployment 8
2018-06-22 10:28:57.263 +00:00 [INF] - Updated reported properties
2018-06-22 10:29:02.268 +00:00 [INF] - HealthRestartPlanner is clearing restart stats for module 'tempSensor' as it has been running healthy for 00:10:00.
2018-06-22 10:29:02.268 +00:00 [INF] - Plan execution started for deployment 8
2018-06-22 10:29:02.268 +00:00 [INF] - Executing command: "Reset health stats for module tempSensor"
2018-06-22 10:29:02.268 +00:00 [INF] - Plan execution ended for deployment 8
2018-06-22 10:29:02.571 +00:00 [INF] - Updated reported properties
edgeHub:
2018-06-22 10:26:14.438 +00:00 [INF] - Attempting to connect to IoT Hub for client xxxdevice/filterModule via AMQP over WebSocket...
2018-06-22 10:26:14.439 +00:00 [INF] - New token requested by client xxxdevice/filterModule, but using existing token as it is usable.
2018-06-22 10:26:14.789 +00:00 [INF] - Connected to IoT Hub for client xxxdevice/filterModule via AMQP over WebSocket, with client operation timeout 60000.
2018-06-22 10:26:14.793 +00:00 [INF] - Closed cloud proxy for device xxxdevice/filterModule
2018-06-22 10:26:14.793 +00:00 [INF] - No session state found in store for xxxdevice/filterModule
2018-06-22 10:26:14.793 +00:00 [INF] - New cloud connection created for device xxxdevice/filterModule
2018-06-22 10:26:14.793 +00:00 [INF] - Successfully authenticated device xxxdevice/filterModule
2018-06-22 10:26:14.793 +00:00 [INF] - Successfully generated identity for clientId xxxdevice/filterModule and username xxx-iothub.azure-devices.net/xxxdevice/filterModule/api-version=2016-11-14&DeviceClientType=iothubclient%2f1.1.31%20(native%3b%20Linux%3b%20x86_64)
2018-06-22 10:26:14.793 +00:00 [INF] - ClientAuthenticated, xxxdevice/filterModule, 084e3167
2018-06-22 10:28:26.580 +00:00 [INF] - Attempting to connect to IoT Hub for client xxxdevice/filterModule via AMQP...
2018-06-22 10:29:26.583 +00:00 [INF] - Attempting to connect to IoT Hub for client xxxdevice/filterModule via AMQP over WebSocket...
2018-06-22 10:29:26.584 +00:00 [INF] - New token requested by client xxxdevice/filterModule, but using existing token as it is usable.
2018-06-22 10:29:26.918 +00:00 [INF] - Connected to IoT Hub for client xxxdevice/filterModule via AMQP over WebSocket, with client operation timeout 60000.
2018-06-22 10:29:26.919 +00:00 [INF] - Closed cloud proxy for device xxxdevice/filterModule
2018-06-22 10:29:26.923 +00:00 [INF] - No session state found in store for xxxdevice/filterModule
2018-06-22 10:29:26.923 +00:00 [INF] - New cloud connection created for device xxxdevice/filterModule
2018-06-22 10:29:26.924 +00:00 [INF] - Successfully authenticated device xxxdevice/filterModule
2018-06-22 10:29:26.924 +00:00 [INF] - Successfully generated identity for clientId xxxdevice/filterModule and username xxx-iothub.azure-devices.net/xxxdevice/filterModule/api-version=2016-11-14&DeviceClientType=iothubclient%2f1.1.31%20(native%3b%20Linux%3b%20x86_64)
2018-06-22 10:29:26.924 +00:00 [INF] - ClientAuthenticated, xxxdevice/filterModule, 126cb7eb
2018-06-22 10:31:33.659 +00:00 [ERR] - Module filterModule is not connected
过滤器:
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609]
IoT Hub Client for Python
Adding TrustedCerts from: /mnt/edgemodule/edge-device-ca.cert.pem
set_option TrustedCerts successful
Starting the IoT Hub Python sample using protocol MQTT...
The sample is now waiting for messages and will indefinitely. Press Ctrl-C to exit.
Error: Time:Fri Jun 22 10:28:57 2018 File:/usr/sdk/src/c/iothub_client/src/iothubtransport_mqtt_common.c Func:InitializeConnection Line:2003 mqtt_client timed out waiting for CONNACK
这是无限重复的。集线器似乎确实注意到了过滤器,但身份验证成功,但访问仍然被拒绝。这可能是 Python SDK 中的一个错误,因为正如我所说,它与 C#-Version 完美配合(在其他情况下相同)。还是有可能是防火墙问题。我真的不这么认为,因为过滤器日志表明存在 MQTT 问题。据我了解,MQTT 仅适用于内部边缘设备流量,而不适用于传出流量(docker 和设备外部)。所以防火墙应该不是问题(?) 实际问题显然是等待集线器确认连接的超时。所以要么集线器没有收到连接请求,要么没有回复,要么回复以某种方式丢失。
提前感谢所有帮助。
【问题讨论】:
标签: python azure-iot-hub azure-iot-edge