如何为IOTHUB提供运输处理程序?

发布于 2025-02-06 18:34:15 字数 2101 浏览 2 评论 0原文

我正在尝试连接到Iothub以配备设备。

我在一个大风WASM应用程序中。

我已经创建了安全提供商对称密钥:

SecurityProvider symmetricKeyProvider = new SecurityProviderSymmetricKey(parameters.DeviceId, parameters.DeviceSymmetricKey, null);

但是我要调用的下一行:

            ProvisioningTransportHandler mqttTransportHandler = new ProvisioningTransportHandlerMqtt(TransportFallbackType.TcpOnly);

我已经尝试了TCPonly后备,并且没有传递任何后备,并且都给了我同样的错误。例外是:

Error provisioning device: The type initializer for 'Microsoft.Azure.Devices.Provisioning.Client.Transport.ProvisioningTransportHandlerMqtt' threw an exception.
System.TypeInitializationException: The type initializer for 'Microsoft.Azure.Devices.Provisioning.Client.Transport.ProvisioningTransportHandlerMqtt' threw an exception.
 ---> System.InvalidOperationException: failed to create a child event loop.
 ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.Threading.Thread.Start()
   at DotNetty.Common.Concurrency.SingleThreadEventExecutor..ctor(IEventExecutorGroup parent, String threadName, TimeSpan breakoutInterval, IQueue`1 taskQueue)
   at DotNetty.Common.Concurrency.SingleThreadEventExecutor..ctor(IEventExecutorGroup parent, String threadName, TimeSpan breakoutInterval)
   at DotNetty.Transport.Channels.SingleThreadEventLoop..ctor(IEventLoopGroup parent, String threadName, TimeSpan breakoutInterval)
   at DotNetty.Transport.Channels.SingleThreadEventLoop..ctor(IEventLoopGroup parent)
   at DotNetty.Transport.Channels.MultithreadEventLoopGroup.<>c.<.cctor>b__24_0(IEventLoopGroup group)
   at DotNetty.Transport.Channels.MultithreadEventLoopGroup..ctor(Func`2 eventLoopFactory, Int32 eventLoopCount)
   --- End of inner exception stack trace ---
   at DotNetty.Transport.Channels.MultithreadEventLoopGroup..ctor(Func`2 eventLoopFactory, Int32 eventLoopCount)
   at DotNetty.Transport.Channels.MultithreadEventLoopGroup..ctor()
   at Microsoft.Azure.Devices.Provisioning.Client.Transport.ProvisioningTransportHandlerMqtt..cctor()

I am trying to connect to IoTHub to provision my device.

I am in a Blazor WASM app.

I have created the Security Provider Symmetric Key via:

SecurityProvider symmetricKeyProvider = new SecurityProviderSymmetricKey(parameters.DeviceId, parameters.DeviceSymmetricKey, null);

However my next line I call:

            ProvisioningTransportHandler mqttTransportHandler = new ProvisioningTransportHandlerMqtt(TransportFallbackType.TcpOnly);

I have tried it with both the TcpOnly fallback along with not passing in any fallback and both give me the same error. The exception is:

Error provisioning device: The type initializer for 'Microsoft.Azure.Devices.Provisioning.Client.Transport.ProvisioningTransportHandlerMqtt' threw an exception.
System.TypeInitializationException: The type initializer for 'Microsoft.Azure.Devices.Provisioning.Client.Transport.ProvisioningTransportHandlerMqtt' threw an exception.
 ---> System.InvalidOperationException: failed to create a child event loop.
 ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.Threading.Thread.Start()
   at DotNetty.Common.Concurrency.SingleThreadEventExecutor..ctor(IEventExecutorGroup parent, String threadName, TimeSpan breakoutInterval, IQueue`1 taskQueue)
   at DotNetty.Common.Concurrency.SingleThreadEventExecutor..ctor(IEventExecutorGroup parent, String threadName, TimeSpan breakoutInterval)
   at DotNetty.Transport.Channels.SingleThreadEventLoop..ctor(IEventLoopGroup parent, String threadName, TimeSpan breakoutInterval)
   at DotNetty.Transport.Channels.SingleThreadEventLoop..ctor(IEventLoopGroup parent)
   at DotNetty.Transport.Channels.MultithreadEventLoopGroup.<>c.<.cctor>b__24_0(IEventLoopGroup group)
   at DotNetty.Transport.Channels.MultithreadEventLoopGroup..ctor(Func`2 eventLoopFactory, Int32 eventLoopCount)
   --- End of inner exception stack trace ---
   at DotNetty.Transport.Channels.MultithreadEventLoopGroup..ctor(Func`2 eventLoopFactory, Int32 eventLoopCount)
   at DotNetty.Transport.Channels.MultithreadEventLoopGroup..ctor()
   at Microsoft.Azure.Devices.Provisioning.Client.Transport.ProvisioningTransportHandlerMqtt..cctor()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文