SignalR超过2个连接失败 [英] SignalR Fails with more than 2 connections

查看:347
本文介绍了SignalR超过2个连接失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在SignalR中编写了一个相当简单的聊天应用程序.

I have written a fairly simple chat application in SignalR.

如果我连接的标签/浏览器/设备超过2个,则第三个标签将挂起并且永远不会连接,最终会导致问题.

It seems if i connect with more than 2 tabs/browsers/devices the third will hang and never connect and eventually cause problems.

为什么我只能与2个用户建立联系?

Why can I only connect with 2 users?

当我断开另一个2的连接后,第三个请求就会通过.

The third request goes through as soon as I disconnect one of the other 2.

我使用的是同一用户还是不同的用户都没关系.

Doesn't matter if I use the same user or different users.

我在Windows 10,带有SignalR 2.2的Asp.Net MVC5上使用IIS

I am using IIS on Windows 10, Asp.Net MVC5 with SignalR 2.2

它从不调用中心代码,如果在打开该选项卡时尝试与第四个客户端连接,则第四个选项卡甚至都不会返回视图.

It never calls the hub code, if I try to connect with a fourth client while that tab is open the fourth tab won't even return the view.

$.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永远不会在第三个连接中命中.

console.log is never hit for the third connection.

$.connection.hub.start()

被击中,并且连接和集线器的值都不为空.

Is hit, and the connection and hub have values that aren't null.

  public override Task OnConnected()
    {

除非我终止其他两个连接中的一个,否则从不连接第三个连接.因此,共享这些方法/功能的内部结构只会增加我的困惑.

Is never hit on the third connection unless I terminate one of the other two. So sharing the internals of these methods/functions would only add confusion I feel.

$.connection.hub.starting(function () {
    console.log('starting')
});
$.connection.hub.received(function () {
    console.log('connection received')
});

在第三个客户端上,开始将其放置在控制台中,但是没有收到.

On the third client, starting his put in the console but received isn't.

推荐答案

我相信在拔掉许多头发并感到沮丧之后,我才能够找到答案.

I believe I was able to discover the answer to this after much hair pulling out and frustration.

因为桌面IIS仅允许10个并发连接,并且websocket连接是如此动态,所以我认为它充当了10个连接,只有2个实际连接. http://www.asp.net/signalr/overview/getting-started/supported-platforms

Because desktop IIS only allows 10 concurrent connections and websocket connections are so dynamic I think that it was acting as 10 connections with only 2 actual connections. http://www.asp.net/signalr/overview/getting-started/supported-platforms

不应使用IIS或Cassini的完整版本,因为这样会 限制10个并发连接,这将是 由于连接是瞬态的,因此可以很快达到 重新建立,并且不再不再被立即处置 用过的. IIS Express应该在客户端操作系统上使用."

"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并从命令提示符下运行它,以便在服务器启动时进行开发. 这是公开IIS Express的方法 去 c:\ Users [您的名字] \ Documents \ IISExpress \ config \ applicationhost.config

As a work around I am going to use IIS Express, my reasoning behind not wanting to was becauase I wanted my site exposed so my co-workers could connect and sanity test. I figured out how to expose IIS to the web and run it from a command prompt so I can develop while the server is up. This is how to expose IIS Express Go to c:\Users[YourName]\Documents\IISExpress\config\applicationhost.config

添加(适当替换IP地址和端口):

Add(replacing IP address and port appropriately):

<binding protocol="http" bindingInformation="*:58938:192.168.1.42" />

到相关站点.

正在运行IIS从命令行

打开命令提示符.

Open a command prompt.

您不需要管理员用户权限即可运行此命令 演练.但是,如果您具有管理员用户权限,则必须 想要在端口号为1024或更少的端口上运行IIS Express.跑过 以下命令导航到IIS Express安装文件夹:

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 

,或者如果您使用的是64位操作系统,请运行 以下命令:cd \ Program Files(x86)\ IIS Express运行 以下命令查看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

当然不要忘记端口转发和防火墙通过.

and of course don't forget about port forwarding and firewall pass through.

这篇关于SignalR超过2个连接失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆