【发布时间】:2018-09-18 20:58:23
【问题描述】:
我已按照所有说明设置“下游设备”以通过在透明网关中运行的 IoT Edge 发送消息。我相信我的路由规则是正确的,但我的功能模块没有通过消息流接收任何消息。
这些是我遵循的说明: https://docs.microsoft.com/en-us/azure/iot-edge/how-to-create-transparent-gateway-linux
我正在使用 2 个 Linxu 虚拟机(ubuntu 16.04.5)。
- IoT Edge 透明网关 VM 配置有正确设置、配置和验证的所有证书。我已经能够使用来自 的 openssl 工具
openssl s_client -connect {my-gateway-machine-name-dns-name}.centralus.cloudapp.azure.com:8883 -CAfile /certs/certs/azure-iot-test-only.root.ca.cert .pem -showcerts
-
在安装并验证了证书的 Linux VM 上运行的下游设备。我的连接字符串如下:
HostName={IoTHubName}.azure-devices.net;DeviceId=TC51_EdgeDownStreamDevice01;SharedAccessKey={My-Shared-Access-Key}=GatewayHostName={my-gateway-machine-name-dns-name}.centralus.cloudapp .azure.com
一个。我已经验证我使用 openssl 工具成功验证了 SSL 证书。 湾。我在下游设备中使用以下内容使用 NodeJS SDK 进行连接
var client = DeviceClient.fromConnectionString(connectionString, Mqtt); C。我可以看到消息显示在云中的 Azure IoT 中心,但我无法让我的模块在 IoT Edge 透明网关上运行。
- 这是我为 edgeHub 配置的路由规则,在示例文档页面的“路由来自下游设备的消息”中指定。
这是示例文档显示的内容: { "routes":{ "sensorToAIInsightsInput1":"FROM /messages/* WHERE NOT IS_DEFINED($connectionModuleId) INTO BrokeredEndpoint(\"/modules/ai_insights/inputs/input1\")", "AIInsightsToIoTHub":"FROM /messages/模块/ai_insights/outputs/output1 INTO $upstream" } }
这是我的路由配置设置为: “路线”:{ "downstreamBatterySensorToBatteryDataFunctionInput1": "FROM /* WHERE NOT IS_DEFINED($connectionModuleId) INTO BrokeredEndpoint(\"/modules/BatteryDataFunctionModule/inputs/input1\")", “BatteryDataFunctionModuleToIoTHub”:“从 /messages/modules/BatteryDataFunctionModule/outputs/* INTO $upstream” }
** 请注意,我使用了“FROM /* WHERE NOT IS_DEFINED”和“FROM /messages/* WHERE NOT IS_DEFINED”
- 我在 IoT Edge 上的模块设置为函数。当我使用开箱即用的示例时,其中模拟器设备是在 IoT Edge 上运行的另一个模块,然后我的函数被正确命中。只有当我尝试使用“下游设备”时才会触发模块。
我已启用在透明网关上运行的“IoT Edge 服务的调试日志记录”。
This is the basic Run method for the Function module:
#r "Microsoft.Azure.Devices.Client"
#r "Newtonsoft.Json"
using System.IO;
using Microsoft.Azure.Devices.Client;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
// Filter messages based on the temperature value in the body of the message and the temperature threshold value.
public static async Task Run(Message messageReceived, IAsyncCollector<Message> output, TraceWriter log)
{
如何确定如何让我的模块在 IoT Edge 中运行以被下游设备命中/触发?
【问题讨论】:
标签: azure iot azure-iot-hub azure-iot-edge