Blazor web assembly
Hello, im trying to create a websocket and make a connection to remote server but there is something i dont get. the code that im using is
`var url = new Uri(urlString + connectparams); _client = new WebsocketClient(url); _client.ReconnectTimeout = TimeSpan.FromSeconds(120); _client.ErrorReconnectTimeout = TimeSpan.FromSeconds(30); _client.ReconnectionHappened.Subscribe(info => { Console.WriteLine($"Reconnection happened, type: {info.Type}, url: {_client.Url}"); Log($"Reconnected, type: '{info.Type}'", LogSeverity.Warning); StateHasChanged(); }); _client.DisconnectionHappened.Subscribe(info => { Console.WriteLine($"Disconnection happened, type: {info.Exception}"); Console.WriteLine($"Disconnected, type: '{info.Type}', reason: '{info.CloseStatus}'", LogSeverity.Warning); //Console.WriteLine($"Disconnected, type: '{info.ToString()}', reason: '{info.CloseStatus}'", LogSeverity.Warning); StateHasChanged(); });
_client.MessageReceived.Subscribe(msg =>
{
Console.WriteLine($"Message received: {msg}");
Log($"Received: '{msg.Text}'", LogSeverity.Info);
StateHasChanged();
});
Console.WriteLine("Starting...");
await _client.Start();
//sendHello();
Console.WriteLine("Started.");`
and the error im getting is
Disconnection happened, type: System.Net.WebSockets.WebSocketException (0x80004005): WebSocket connection failure. ---> System.Net.WebSockets.WebSocketException (0x80004005): An internal WebSocket error occurred. Please see the innerException, if present, for more details.
at WebAssembly.Net.WebSockets.ClientWebSocket.ConnectAsyncJavaScript (System.Uri uri, System.Threading.CancellationToken cancellationToken) <0x31622c0 + 0x00442> in
Hi @dinos19,
are you using the latest version 4.4.43?
I was able to make it work in Blazor wasm, see project here: https://github.com/Marfusios/crypto-watcher-blazor
There was an issue with KeepAliveInterval that is not supported in wasm platform.
So the latest version doesn't set KeepAliveInterval and leaves it to the default value.