SignalR 挂起启动连接 [英] SignalR pending start connection
问题描述
我正在实现 SignalR 库,以便在 ASP.NET MVC 应用程序中的一种队列"中使用 websocket.
I'm implementing the SignalR library to use websocket in a kind of 'queue', in a ASP.NET MVC Application.
当只有两个用户时,一切都按预期进行.当第三个用户登录时(我的意思是,我打开一个新标签页),他的 SignalR 启动请求处于待处理状态,其他用户无法再使用应用程序.
Everything works as expected when there are only two users. When a third one logs in (I mean, I open a new tab), his SignalR start request is pending, and other users can not use application anymore.
所有浏览器都会发生这种情况:如果我打开 3 个 Chrome 标签页,或 3 个 Firefox,或 2 个 Chrome 或 1 个 Firefox,或 2 个 Firefox 和 1 个 Chrome.. 它将永远待处理.
It's happening with all browsers: if I open 3 Chrome tabs, or 3 Firefox, or 2 Chrome or 1 Firefox, or 2 Firefox and 1 Chrome.. it's pending forever.
我的代码与为 SignalR 教程提供的代码相同:信号 R 2 和 MVC 5 入门".
My code is the same as the one provided for SignalR tutorials: "Getting Started with SignalR 2 and MVC 5".
谁能解决这个问题?我开始认为这是 IIS 限制,但我不是 100% 确定.我使用的是最新的 SignalR 版本 (2.3.0)、4.6.1 ASP 版本(我已经在 IIS 配置中启用了 WebSockets).
Could anyone solve this? I'm starting to think that is an IIS limitation, but I'm not 100% sure. I'm using the last SignalR version (2.3.0), 4.6.1 ASP version (I already enabled WebSockets in the IIS configuration).
我发现了一个类似的问题(SignalR start pending)但似乎没有给出答案.
I've found a similar question (SignalR start pending) but it doesn't seem to give an answer.
JavaScript(客户端)代码:
JavaScript (client) code:
var attendHub = $.connection.attendHub;
// Create a function that the hub can call back
attendHub.client.reloadGrid = function (sr) {
// Business logic
}
};
$.connection.hub.start();
服务器中心 (C#) 代码:
Server Hub (C#) code:
public class AttendHub : Hub
{
private static readonly IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<AttendHub>();
public static void RefreshAttendList(int branchId)
{
// Business logic
///...
hubContext.Clients.All.ReloadGrid(sr);
}
}
我正在从控制器调用 RefreshAttendList 方法,执行这一行:
And I'm calling the RefreshAttendList method from a controller, executing this line:
AttendHub.RefreshAttendList(AppInfo.ActiveUser.BranchId);
我可能做错了什么?
推荐答案
好吧,我发现这是一个本地 IIS 限制,因为我将配置更改为使用 IIS Express 而不是本地,并且它的工作非常出色!
Well, I figured out that it was a Local IIS limitation, because I changed the configuration to use IIS Express instead of Local, and it's working like a charm!
希望对遇到同样问题的人有所帮助!
Hope this helps to anyone with the same issue!
这篇关于SignalR 挂起启动连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!