在连接到同一服务 URI 的单个进程中使用 ServerEventsClient 的多个实例
Using multiple instances of ServerEventsClient in single process connecting to same service URI
当我在连接到同一 URI 的单个 .NET 应用程序中使用多个 ServerEventsClient 实例时,任何后续 GET/POST 等调用都会无限期地阻塞并超时。我相信这与@mythz (Timeout using ServiceStack.Client) 在这个答案中提到的某些 DDoS 保护有关。只有当服务器和客户端不在同一台 PC 上 运行 时才会发生这种情况。
我可以通过确保只为给定的 URI 创建一个 ServerEventsClient 来解决这个问题,但是在我投入太多工作之前,我想确保这是设计使然并且没有更简单的解决方法处理这个。还有其他人 运行 关注这个问题吗?
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>
当我在连接到同一 URI 的单个 .NET 应用程序中使用多个 ServerEventsClient 实例时,任何后续 GET/POST 等调用都会无限期地阻塞并超时。我相信这与@mythz (Timeout using ServiceStack.Client) 在这个答案中提到的某些 DDoS 保护有关。只有当服务器和客户端不在同一台 PC 上 运行 时才会发生这种情况。
我可以通过确保只为给定的 URI 创建一个 ServerEventsClient 来解决这个问题,但是在我投入太多工作之前,我想确保这是设计使然并且没有更简单的解决方法处理这个。还有其他人 运行 关注这个问题吗?
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>