ably / ably-dotnet

.NET, MAUI, Xamarin, Mono and Unity client library SDK for Ably realtime messaging service
https://ably.com/download
Apache License 2.0
45 stars 22 forks source link

Creation of AblyRealtime client in Blazor apps results in PlatformNotSupportedException #1152

Open marcduiker opened 2 years ago

marcduiker commented 2 years ago

Expected behavior

The AblyRealtime instance is created without issues.

Actual behavior

When the AblyRealtime instance is created the following exception is thrown:

System.AggregateException: One or more errors occurred. (The type initializer for 'IO.Ably.Encryption.Crypto' threw an exception.)
 ---> System.TypeInitializationException: The type initializer for 'IO.Ably.Encryption.Crypto' threw an exception.
 ---> System.PlatformNotSupportedException: System.Security.Cryptography.Csp is not supported on this platform.
   at System.Security.Cryptography.RNGCryptoServiceProvider..ctor()
   at IO.Ably.Encryption.Crypto..cctor()
   --- End of inner exception stack trace ---
   at IO.Ably.ChannelOptions..ctor(ILogger logger, Boolean encrypted, CipherParams params, ChannelModes modes, ChannelParams channelParams)
   at IO.Ably.ChannelOptions..ctor(Boolean encrypted, CipherParams params, ChannelModes modes, ChannelParams channelParams)
   at IO.Ably.ClientOptions..ctor()
   at Program.<Main>$(String[] args) in C:\dev\ably-labs\serverless-websockets-quest\ServerlessWebsocketsQuest.Client\Program.cs:line 11
   --- End of inner exception stack trace ---

Impact

It seems like Ably can't be used at all in Blazor apps at the moment. WebAssembly is getting quite some traction these days so it would be great if Ably can be used with it.

Cause

This seems to be causing the exception: System.Security.Cryptography APIs not supported on Blazor WebAssembly

Repo to reproduce

https://github.com/ably-labs/serverless-websockets-quest Use the switch-to-blazor branch.

┆Issue is synchronized with this Jira Research by Unito

tomkirbygreen commented 2 years ago

I think we need to treat WebAssembly as a new platform that we build for, and test on. Looping in @AndyNicks to get a product perspective on this.

AndyNicks commented 2 years ago

This research on WebAssembly is put on the roadmap.

MarianoGomezBidondo commented 1 year ago

Any news about it?

mikelee638 commented 1 year ago

Hey @MarianoGomezBidondo, unfortunately no, there is no new news on this. We will let you know if there are updates, thanks for your interest!