SignalR连接不会开始与IIS托管的应用程序 [英] SignalR connection won't start to IIS-hosted app
问题描述
我创建了一个应用程序,并试图通过SignalR连接到后端.
I made an application, and am trying to connect to the backend via SignalR.
ASP.NET Core 3.1后端托管在IIS中,以便于开发.
The ASP.NET Core 3.1 backend is hosted in IIS for easy development.
在客户端上成功调用StartAsync方法进行协商,但随后永久挂在GET上:
Calling the StartAsync method on the client successfully negotiates, but then hangs forever on the GET:
GET http://localhost:81/signalr?id=W3F2TRVrx_lxZoinHzTzmA
StartAsync()调用无法返回.
The StartAsync() call can't return.
这仅在IIS上发生.当我自托管启动应用程序时,它可以工作.
This only happens on IIS. When I start the app self-hosted, it works.
其余的WebAPI也可以在IIS上使用.只是SignalR无法连接.
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.
推荐答案
所以我实际上找到了答案:
So I actually found the answer myself:
Websocket支持默认情况下不在IIS上启用.它是在IIS 8中引入的,必须从Windows的可选功能中启用:
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
可选功能-> IIS-> WWW服务-> App Dev功能-> Websocket协议
Optional features -> IIS -> WWW services -> App Dev Features -> Websocket protocol
这篇关于SignalR连接不会开始与IIS托管的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!