在单个进程中使用多个ServerEventsClient实例连接到相同的服务URI

问题描述 投票:2回答:1

当我在连接到同一URI的单个.NET应用程序中使用多个ServerEventsClient实例时,任何后续GET / POST等调用都会无限期地阻塞并超时。我相信这与@mythz(Timeout using ServiceStack.Client)的回答中提到的一些DDoS保护有关。只有当服务器和客户端没有在同一台PC上运行时才会发生这种情况。

我可以通过确保我只为给定的URI创建一个ServerEventsClient来解决这个问题,但在我投入太多工作之前,我想确保这是设计的,并且没有更简单的解决方法来处理这个问题。还有其他人遇到过这个问题吗?

servicestack server-sent-events
1个回答
0
投票

ServiceStack的C# Server Events Client在幕后使用.NET HttpWebRequest,每个域都有内置的请求限制。

您应该可以通过增加System.Net.ServicePointManager.DefaultConnectionLimit来增加限制,例如:

ServicePointManager.DefaultConnectionLimit = 10;

或者,您应该可以在Web.config中使用<connectionManagement>增加此限制:

<configuration>  
  <system.net>  
    <connectionManagement>  
      <add address = "http://www.contoso.com" maxconnection = "4" />  
      <add address = "*" maxconnection = "10" />  
    </connectionManagement>  
  </system.net>  
</configuration>  
© www.soinside.com 2019 - 2024. All rights reserved.