SignalR 因超过 2 个连接而失败
SignalR Fails with more than 2 connections
我用 SignalR 编写了一个相当简单的聊天应用程序。
似乎如果我连接超过 2 个 tabs/browsers/devices 第三个将挂起并且永远不会连接并最终导致问题。
为什么我只能连接2个用户?
第三个请求在我断开另外两个请求中的一个时立即通过。
无论我使用相同的用户还是不同的用户都无所谓。
我在 Windows 10、Asp.Net MVC5 和 SignalR 2.2
上使用 IIS
它从不调用中心代码,如果我在该选项卡打开时尝试连接第四个客户端,第四个选项卡甚至 return 都不会显示。
$.connection.hub.start().done(function () {
//add all existing messages when we start the connection
//chat.server.addExistingMessages();
console.log('Now connected, connection ID=' + $.connection.hub.id);
console.log 永远不会为第三个连接命中。
$.connection.hub.start()
命中,连接和集线器的值不为空。
public override Task OnConnected()
{
除非我终止另外两个连接之一,否则永远不会在第三个连接上命中。因此,共享这些 methods/functions 的内部结构只会增加我的困惑。
$.connection.hub.starting(function () {
console.log('starting')
});
$.connection.hub.received(function () {
console.log('connection received')
});
在第三个客户端上,开始他在控制台中的输入但接收不到。
我相信在经历了很多头发拔除和挫折之后,我能够找到这个问题的答案。
因为桌面 IIS 只允许 10 个并发连接,而 websocket 连接是如此动态,我认为它充当 10 个连接而只有 2 个实际连接。
http://www.asp.net/signalr/overview/getting-started/supported-platforms
"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 systems."
如果不是这样,请大家指正!
作为解决方法,我将使用 IIS Express,我不想这样做的原因是因为我希望公开我的站点,以便我的同事可以连接并进行健全性测试。我想出了如何将 IIS 公开到 Web 并从命令提示符 运行 它,这样我就可以在服务器启动时进行开发。
This is how to expose IIS Express
去
c:\Users[你的名字]\Documents\IISExpress\config\applicationhost.config
添加(适当替换IP地址和端口):
<binding protocol="http" bindingInformation="*:58938:192.168.1.42" />
前往相关网站。
Open a command prompt.
You do not need Administrator user rights to run the commands in this
walkthrough. However, you must have Administrator user rights if you
want to run IIS Express on ports numbered 1024 or less. Run the
following command to navigate to the IIS Express installation folder:
cd \Program Files\IIS Express
or if you are using a 64-bit OS, run the
following command: cd \Program Files (x86)\IIS Express Run the
following command to view the IIS Express usage string:
iisexpress /site:site-name
当然不要忘记端口转发和防火墙通过。
我用 SignalR 编写了一个相当简单的聊天应用程序。
似乎如果我连接超过 2 个 tabs/browsers/devices 第三个将挂起并且永远不会连接并最终导致问题。
为什么我只能连接2个用户?
第三个请求在我断开另外两个请求中的一个时立即通过。
无论我使用相同的用户还是不同的用户都无所谓。
我在 Windows 10、Asp.Net MVC5 和 SignalR 2.2
上使用 IIS它从不调用中心代码,如果我在该选项卡打开时尝试连接第四个客户端,第四个选项卡甚至 return 都不会显示。
$.connection.hub.start().done(function () {
//add all existing messages when we start the connection
//chat.server.addExistingMessages();
console.log('Now connected, connection ID=' + $.connection.hub.id);
console.log 永远不会为第三个连接命中。
$.connection.hub.start()
命中,连接和集线器的值不为空。
public override Task OnConnected()
{
除非我终止另外两个连接之一,否则永远不会在第三个连接上命中。因此,共享这些 methods/functions 的内部结构只会增加我的困惑。
$.connection.hub.starting(function () {
console.log('starting')
});
$.connection.hub.received(function () {
console.log('connection received')
});
在第三个客户端上,开始他在控制台中的输入但接收不到。
我相信在经历了很多头发拔除和挫折之后,我能够找到这个问题的答案。
因为桌面 IIS 只允许 10 个并发连接,而 websocket 连接是如此动态,我认为它充当 10 个连接而只有 2 个实际连接。 http://www.asp.net/signalr/overview/getting-started/supported-platforms
"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 systems."
如果不是这样,请大家指正!
作为解决方法,我将使用 IIS Express,我不想这样做的原因是因为我希望公开我的站点,以便我的同事可以连接并进行健全性测试。我想出了如何将 IIS 公开到 Web 并从命令提示符 运行 它,这样我就可以在服务器启动时进行开发。 This is how to expose IIS Express 去 c:\Users[你的名字]\Documents\IISExpress\config\applicationhost.config
添加(适当替换IP地址和端口):
<binding protocol="http" bindingInformation="*:58938:192.168.1.42" />
前往相关网站。
Open a command prompt.
You do not need Administrator user rights to run the commands in this walkthrough. However, you must have Administrator user rights if you want to run IIS Express on ports numbered 1024 or less. Run the following command to navigate to the IIS Express installation folder:
cd \Program Files\IIS Express
or if you are using a 64-bit OS, run the following command: cd \Program Files (x86)\IIS Express Run the following command to view the IIS Express usage string:
iisexpress /site:site-name
当然不要忘记端口转发和防火墙通过。