diff --git a/README.md b/README.md index 274e92e4..32d35da0 100644 --- a/README.md +++ b/README.md @@ -139,3 +139,9 @@ subscription.Dispose(); * [GitHub GraphQL API Docs](https://developer.github.com/v4/guides/forming-calls/) * [GitHub GraphQL Explorer](https://developer.github.com/v4/explorer/) * [GitHub GraphQL Endpoint](https://api.github.com/graphql) + +## Blazor WebAssembly Limitations + +Blazor WebAssembly differs from other platforms as it does not support all features of other .NET runtime implementations. For instance, the following WebSocket options properties are not supported and will not be set: +* [ClientCertificates](https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocketoptions.clientcertificates?view=netcore-3.1#System_Net_WebSockets_ClientWebSocketOptions_ClientCertificates) +* [UseDefaultCredentials](https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocketoptions.usedefaultcredentials?view=netcore-3.1) diff --git a/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs b/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs index 663a7f0d..fec76d34 100644 --- a/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs +++ b/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs @@ -407,8 +407,22 @@ public Task InitializeWebSocket() #else _clientWebSocket = new ClientWebSocket(); _clientWebSocket.Options.AddSubProtocol("graphql-ws"); - _clientWebSocket.Options.ClientCertificates = ((HttpClientHandler)Options.HttpMessageHandler).ClientCertificates; - _clientWebSocket.Options.UseDefaultCredentials = ((HttpClientHandler)Options.HttpMessageHandler).UseDefaultCredentials; + try + { + _clientWebSocket.Options.ClientCertificates = ((HttpClientHandler)Options.HttpMessageHandler).ClientCertificates; + } + catch (PlatformNotSupportedException) + { + Debug.WriteLine("unable to set Options.ClientCertificates property; platform does not support it"); + } + try + { + _clientWebSocket.Options.UseDefaultCredentials = ((HttpClientHandler)Options.HttpMessageHandler).UseDefaultCredentials; + } + catch (PlatformNotSupportedException) + { + Debug.WriteLine("unable to set Options.UseDefaultCredentials property; platform does not support it"); + } Options.ConfigureWebsocketOptions(_clientWebSocket.Options); #endif return _initializeWebSocketTask = ConnectAsync(_internalCancellationToken);