As mentioned here: Http/2 WebSockets support
.NET 7 introduced Websockets over HTTP/2 support for Kestrel, the SignalR JavaScript client, and SignalR with Blazor WebAssembly.
Note:
HTTP/2 WebSockets use CONNECT requests rather than GET, so your own routes and controllers may need updating.
Which means that you have to change [HttpGet("/path")]
by [Route("/path")]
as mentioned here: Add HTTP/2 WebSockets support for existing controllers
But now my socket doesn’t connect anymore.
It also says:
Chrome and Edge have HTTP/2 WebSockets enabled by default, and you can enable it in FireFox on the
about:config
page with thenetwork.http.spdy.websockets
flag.
But I’m using Chrome and it seems that it is not enabled by default.
- How can I verify if it’s enabled (and Websocket uses
CONNECT
instead ofGET
)? - Or even better, how can I fix my problem (my code is a copy/paste from the
WebSocketController
provided in the documentation)?