Search code examples
signalrblazorblazor-server-side

Why is Blazor using post instead of WebSockets?


I have a Blazor Server app. When I run the app in Visual Studio, I see this message in the Browser console:

 WebSocket connected to wss://localhost:44329/_blazor?id=HX5t9UdbZwj35PkMxV3Fkw.

So it looks to me like SignalR is working as expected. On the Network Tab, I see signalR working as expected with message:

However, now I publish the App to IIS. The app works fine. However, if I look in the browser console, I no longer see WebSocket being connected. What I see in the network tab looks like this:

Request URL: https://blazor/_blazor?id=O_acVtnuEIOjlRAosu1YFg
Request Method: POST

There are many many of these like 1 per second.

So it looks like SignalR is no longer being used.

Why is this? What do I need to do to ensure SignalR is being used?


Solution

  • Make sure WebSockets has been enabled on IIS. Here is a brief overview:

    https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support