ASP.NET Core SignalR Websocket连接限制 [英] ASP.NET Core SignalR websocket connection limit

查看:143
本文介绍了ASP.NET Core SignalR Websocket连接限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Microsoft.AspNetCore.SignalR.Client进行以Windows Server 2016标准托管的SignalR(ASP.NET Core)应用程序的负载测试.安装了Dotnet Core Hosting 2.1.1

I produce load testing of SignalR (ASP.NET Core) application hosted at Windows Server 2016 standard using Microsoft.AspNetCore.SignalR.Client. Dotnet core hosting 2.1.1 installed

我创建的连接数不能超过3000(2950-3050).

And i can not create more than 3000 (2950-3050) connections.

已按如下所述尝试过推荐:

Already tried recomendations as described here:

UseKestrel 添加了限制(如果我将值设置为100或1000,这似乎可行):

Added limits to UseKestrel (this seems to work if i set values to 100 or 1000):

var host = new WebHostBuilder()
    .UseKestrel(options =>
    {
        options.Limits.MaxConcurrentConnections = 50000;
        options.Limits.MaxConcurrentUpgradedConnections = 50000;
    })

通过添加以下内容更改了所有aspnet.config文件:

Changed all aspnet.config files by adding this:

<system.web>
    <applicationPool maxConcurrentRequestsPerCPU="50000" />
</system.web>

执行此命令:

cd%windir%\ System32 \ inetsrv \ appcmd.exe设置配置/section:system.webserver/serverRuntime/appConcurrentRequestLimit:50000

cd %windir%\System32\inetsrv\ appcmd.exe set config /section:system.webserver/serverRuntime /appConcurrentRequestLimit:50000

Web服务\当前连接-最大连接添加了性能计数器.并且最大连接数"增加到3300并停止.

Added performance counter for Web Service\Current Connections - Maximum Connections. And Maximum Connections increases to 3300 and stops.

服务器日志中没有例外.但是我觉得系统上有一些限制.

There are no exceptions in server logs. But I feel that there are some restrictions in system.

服务器IIS日志仅包含以下内容:

Server IIS logs contains only this:

GET/messageshubid = A_3x1sH9kHM1Rc3oPSgP6w80-172.20.192.11--404 0 0 3

GET /messageshub id=A_3x1sH9kHM1Rc3oPSgP6w 80 - 172.20.192.11 - - 404 0 0 3

客户端异常基本上如下:

Client exceptions is basically the following:

System.Net.Http.HttpRequestException:将内容复制到文件时出错溪流.---> System.IO.IOException:无法从传输连接:现有连接被强制关闭远程主机.

System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

推荐答案

在Windows上,您可能会遇到动态端口分配问题.Windows默认情况下可以将5000个端口号分配给TCP连接,其中1024个是为操作系统本身保留的,最终将为3977个端口免费分配.在您的情况下,您提到的数字是3300,但有可能建立了3300个连接,其中有677个为Time_Waited.无论如何,我建议使用

On Windows you may have dynamic port assignment issue . Windows by default has 5000 port numbers ready to be assigned to TCP connections and 1024 of them are reserved for the OS itself which you will end up with 3977 ports free to be assigned . In your case the number is 3300 as you mentioned but it's possible that 3300 of the connections are established and 677 of them are Time_Waited. In any case i recommend to use

netstat -an | find 'Established" -c 
netstat -an | find 'TIME" -c 
netstat -an | find 'CLOSED" -c 

为了弄清已建立&的数量,time_wait&在收到IO异常时关闭close_wait连接,如果数量接近5000,只需将其添加到注册表中,然后重新启动并再次测试

In order to figure out the number of established & time_wait & close_wait connections at the time you received the IO exception and if the number is close to 5000 just add this to your registry and reboot and test again

  [HKEY_LOCAL_MACHINE \System \CurrentControlSet \Services \Tcpip \Parameters]
MaxUserPort = 5000 (Default = 5000, Max = 65534)

这篇关于ASP.NET Core SignalR Websocket连接限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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