从模拟设备代码连接到Edge网关时,面临连接超时,但出现以下异常:
'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientException' in Microsoft.Azure.Devices.Client.dll
Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientException' in mscorlib.dll
Exception thrown: 'System.AggregateException' in Microsoft.Azure.Devices.Client.dll
Exception thrown: 'System.AggregateException' in mscorlib.dll
'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientException' in Microsoft.Azure.Devices.Client.dll
Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientException' in mscorlib.dll
Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientTransientException' in Microsoft.Azure.Devices.Client.dll
Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientTransientException' in mscorlib.dll
Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientTransientException' in Microsoft.Azure.Devices.Client.dll
我正在以正确的格式添加ConnectionString&还包括从https://docs.microsoft.com/en-us/azure/iot-edge/how-to-create-transparent-gateway
配置的GatewayHostName答案 0 :(得分:0)
文章Create an IoT Edge device that acts as a transparent gateway - preview确实可行。使它工作的关键是设置正确的证书。
下面的场景是客户端和边缘都在同一台机器上。
请注意我使用 New-CACertsEdgeDevice myEdgeDevice 来创建设备证书。
iotedgectl setup --connection-string HostName = jierong-iothub.azure-devices.net; DeviceId = jierong-iotedge-device1; SharedAccessKey = XXXXXXX --edge-hostname localhost --device-ca-cert- file myEdgeDevice-public.pem --device-ca-chain-cert-file myEdgeDevice-all.pem --device-ca-private-key-file myEdgeDevice-private.pem --owner-ca-cert-file RootCA.pem 强>
如果你使用本地主机,那么构建你的设备连接字符串如下,不要使用机器名,如下所示:
私有const字符串DeviceConnectionString =“HostName = jierong-iothub.azure-devices.net; DeviceId = jierong-iothub-device; SharedAccessKey = XXXXXXXX; GatewayHostName = localhost”;
修改了以下克隆的应用程序:
git clone https://github.com/Azure-Samples/iot-hub-dotnet-simulated-device-client-app.git
类似的边缘服务器和客户端在两台不同的Win 10机器上,但您应该首先安装证书,如编写以下代码:
如果它仍然无效,请检查您是否没有遇到任何认证验证问题,以及它是如何工作的:
请注意,IoT Edge仍处于预览模式,因此有些内容可能无法刷新。如果您仍然遇到一些问题,我建议您创建支持服务单以进行进一步的故障排除。
谢谢, 杰