[Bug Report] WebSockets not working on Web Assembly
imatrisciano opened this issue · 1 comments
Context
- OS, version, SKU and CPU architecture used: N/A
- Application's .NET Target Framework : net8.0
- Device: Laptop
- SDK version used: 1.42.1
Description of the issue
Connection to IoT Hub fails when the code is run in Blazor WebAssembly, even if a WebSockets transport is selected.
A NotSupportedException
is raised with message Operation is not supported on this platform
Code sample exhibiting the issue
DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(primaryConnectionString, TransportType.Mqtt_WebSocket_Only);
Here a link to a repository to easily replicate the issue: https://github.com/imatrisciano/azure-device-wasm-client-bug
Exception stack trace:
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Operation is not supported on this platform.
System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Net.Http.SocketsHttpHandler.get_SslOptions()
at Microsoft.Azure.Devices.Client.Transport.HttpClientHelper..ctor(Uri baseAddress, IAuthorizationProvider authenticationHeaderProvider, IDictionary`2 defaultErrorMapping, TimeSpan timeout, Http1TransportSettings transportSettings, ProductInfo productInfo, IWebProxy proxy, Boolean isClientPrimaryTransportHandler)
at Microsoft.Azure.Devices.Client.Transport.HttpTransportHandler..ctor(PipelineContext context, IotHubConnectionString iotHubConnectionString, Http1TransportSettings transportSettings, Boolean isClientPrimaryTransportHandler)
at Microsoft.Azure.Devices.Client.InternalClient..ctor(IotHubConnectionString iotHubConnectionString, ITransportSettings[] transportSettings, IDeviceClientPipelineBuilder pipelineBuilder, ClientOptions options)
at Microsoft.Azure.Devices.Client.ClientFactory.CreateFromConnectionString(String connectionString, IAuthenticationMethod authenticationMethod, ITransportSettings[] transportSettings, IDeviceClientPipelineBuilder pipelineBuilder, ClientOptions options)
at Microsoft.Azure.Devices.Client.ClientFactory.CreateFromConnectionString(String connectionString, IAuthenticationMethod authenticationMethod, TransportType transportType, IDeviceClientPipelineBuilder pipelineBuilder, ClientOptions options)
at Microsoft.Azure.Devices.Client.ClientFactory.CreateFromConnectionString(String connectionString, TransportType transportType, ClientOptions options)
at Microsoft.Azure.Devices.Client.DeviceClient.<>c__DisplayClass10_0.b__0()
at Microsoft.Azure.Devices.Client.DeviceClient.Create(Func`1 internalClientCreator)
at Microsoft.Azure.Devices.Client.DeviceClient.CreateFromConnectionString(String connectionString, TransportType transportType, ClientOptions options)
at azure_device_client_bug.Pages.Home.ConnectClient()
at azure_device_client_bug.Pages.Home.OnInitializedAsync()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() blazor.webassembly.js:1:38555
IIRC, we currently don't have any plans to add support for Web assembly, but we are tracking it in the discussion below: