SignalR connection won't start to IIS-hosted a

2020-05-02 04:08发布

问题:

I made an application, and am trying to connect to the backend via SignalR.

The ASP.NET Core 3.1 backend is hosted in IIS for easy development.

Calling the StartAsync method on the client successfully negotiates, but then hangs forever on the GET:

GET http://localhost:81/signalr?id=W3F2TRVrx_lxZoinHzTzmA

The StartAsync() call can't return.

This only happens on IIS. When I start the app self-hosted, it works.

The rest of the WebAPI works on the IIS as well. Just SignalR won't connect.

Any idea why? I found quite a few questions and answers here, but none of them actually solve this precise problem.

回答1:

So I actually found the answer myself:

Websocket support is not enabled by default on IIS. It was introduced in IIS 8, and has to be enabled from windows' optional features: https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support

Optional features -> IIS -> WWW services -> App Dev Features -> Websocket protocol