Websockets no longer working in Blazor WebAssembly (#1755)

* Fix for websockets not applying properties unless explicitly set

* Added comment indicating why properties can't be set

* Update ReleaseNotes.md

---------

Co-authored-by: Christian <6939810+chkr1011@users.noreply.github.com>
This commit is contained in:
Nicke Broström
2023-06-12 21:48:27 +02:00
committed by GitHub
co-authored by Christian
parent 94f9fac2bd
commit 0790e54794
2 changed files with 15 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
* * [Client] Fixed _PlatformNotSupportedException_ when using Blazor (#1755, thanks to @Nickztar).
@@ -221,11 +221,22 @@ namespace MQTTnet.Implementations
#if !NETSTANDARD1_3 #if !NETSTANDARD1_3
#if !WINDOWS_UWP #if !WINDOWS_UWP
clientWebSocket.Options.UseDefaultCredentials = _options.UseDefaultCredentials; // Only set the value if it is actually true. This property is not supported on all platforms
// and will throw a _PlatformNotSupported_ (i.e. WASM) exception when being used regardless of the actual value.
if (_options.UseDefaultCredentials)
{
clientWebSocket.Options.UseDefaultCredentials = _options.UseDefaultCredentials;
}
#endif #endif
clientWebSocket.Options.KeepAliveInterval = _options.KeepAliveInterval; if (_options.KeepAliveInterval != WebSocket.DefaultKeepAliveInterval)
{
clientWebSocket.Options.KeepAliveInterval = _options.KeepAliveInterval;
}
#endif #endif
clientWebSocket.Options.Credentials = _options.Credentials; if (_options.Credentials != null)
{
clientWebSocket.Options.Credentials = _options.Credentials;
}
var certificateValidationHandler = _options.TlsOptions?.CertificateValidationHandler; var certificateValidationHandler = _options.TlsOptions?.CertificateValidationHandler;
if (certificateValidationHandler != null) if (certificateValidationHandler != null)