Native Websockets with Blazor WebAssembly

A couple of days ago, Blazor WebAssembly 3.2.0 Preview 1 was released (announcement). I’m personally excited about this release because it’s the first Blazor release that contains native support for client-side websockets!

Previously, if you wanted to use websockets, you either had to write your own wrapper, or use a larger library like SignalR that did the wrapping for you. However, if you just wanted to use the normal System.Net.WebSockets.ClientWebSocket class that’s built into .NET, you could not.

The Mono/WASM project has actually supported ClientWebSocket for about a year (PR 12615). However, some recent changes in Blazor allowed the Blazor project to be able to consume continue.

tagged as , , , , and