gpt4 book ai didi

c# - SignalR 卡住所有后续的 http 请求

转载 作者:行者123 更新时间:2023-11-30 13:56:49 25 4
gpt4 key购买 nike

我正在尝试在我的 Web 应用程序中使用 SignalR,它托管在 IIS 7.5 上。

我正在使用 Windows 7 X64(没有 SP1)和带有 SignalR v2.0.3.0 的 .Net 4.5。

如果我从 IIS Express 运行 Web 应用程序,它工作正常,没有任何挂断,但一旦我从 IIS 7.5 运行它,它就会挂断我的应用程序。我确认如果我禁用这段代码:

 $.connection.hub.start().done(function () {

});

一切正常。以下是显示集线器启动后所有请求进入无限期阻塞状态的屏幕截图。即使是集线器也需要大约 8-9 秒才能做出响应,但即使在那之后,如果我请求一个简单的 JPG,我也什么也得不到,并且会进入无限期的阻止状态。

enter image description here

这是应用程序池的屏幕截图。我在集成模式下运行。

enter image description here

这是 Hub 类:

 public class AppHub : Hub
{
public override Task OnConnected()
{
if (Context.User != null)
{
var email = Context.User.Identity.Name;
if (!string.IsNullOrEmpty(email))
{
UserRepository userRepository = new UserRepository();
userRepository.DoSomething(email, Context.ConnectionId);
}
}

return base.OnConnected();
}

public override Task OnDisconnected()
{
if (Context.User != null)
{
var email = Context.User.Identity.Name;
if (!string.IsNullOrEmpty(email))
{
UserRepository userRepository = new UserRepository();
userRepository.DoSomething1(email, Context.ConnectionId);
}
}

return base.OnDisconnected();
}
}

最佳答案

文档指出你应该在你的开发机器上使用 IIS express,因为并发请求的数量有限制

When SignalR is hosted in IIS, the following versions are supported. Note that if a client operating system is used, such as for development (Windows 8 or Windows 7), full versions of IIS or Cassini should not be used, since there will be a limit of 10 simultaneous connections imposed, which will be reached very quickly since connections are transient, frequently re-established, and are not disposed immediately upon no longer being used. IIS Express should be used on client operating system

Windows 10 也是如此。

取自此处的 SignalR 文档: http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/supported-platforms

关于c# - SignalR 卡住所有后续的 http 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24276762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com