简体   繁体   English

达到最大连接限制时如何更改 http.sys web 服务器响应

[英]How to change http.sys web server response when maxconnection limit reached

We are using http sys web server to host web api service.我们正在使用 http sys web 服务器来托管 web Z8A5DA52ED126447D359E70C0572 服务。 Business requires to limit maximum number of concurrent connections.业务需要限制最大并发连接数。 MaxConnections configuration property used for that purpose:用于该目的的 MaxConnections 配置属性:

services.Configure<HttpSysOptions>(options =>
{
    options.MaxConnections = Configuration.GetValue<long?>("MaxConnections");
});

But in case when concurrent connection limit reached all new connections got dropped on a socket level.但是,当并发连接限制达到所有新连接时,所有新连接都会在套接字级别被丢弃。 Is it possible to change this behaviour so server accepts the request and returns 4xx or 5xx response to the client?是否可以更改此行为,以便服务器接受请求并向客户端返回 4xx 或 5xx 响应?

I have finally managed to find a solution: there is Http503Verbosity property in options.我终于设法找到了解决方案:选项中有Http503Verbosity属性。 By default it is set to Http503VerbosityLevel.Basic but if to change it to Http503VerbosityLevel.Limited or Http503VerbosityLevel.Full 503 response will be returned for requests above limit.默认情况下,它设置为Http503VerbosityLevel.Basic但如果将其更改为 Http503VerbosityLevel.Limited 或 Http503VerbosityLevel.Full 503 响应将返回超过限制的请求。 So my code looks like this now:所以我的代码现在看起来像这样:

        services.Configure<HttpSysOptions>(options =>
        {
            options.MaxConnections = Configuration.GetValue<long?>("MaxConnections");
            options.Http503Verbosity = Http503VerbosityLevel.Full;
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#NET HTTP.SYS Web服务器 - C# NET HTTP.SYS web server 如何修复 Windows 7 上的“服务器证书未使用 HTTP.SYS 正确配置”? - How to fix “the server certificate is not configured properly with HTTP.SYS” on Windows 7? 使用.Net HttpListener时更改HTTP.sys内核队列限制? - Changing HTTP.sys kernel queue limit when using .Net HttpListener? 在 HTTPS 情况下,服务器证书没有正确配置 HTTP.SYS - server certificate is not configured properly with HTTP.SYS in the HTTPS case 检索HTTP.sys日志 - Retrieving HTTP.sys logs 如何最大化http.sys文件上传性能 - How to maximize http.sys file upload performance 如何使用 HTTP.sys 托管 Blazor 应用程序 (.NET 6) - How to use HTTP.sys to host Blazor app (.NET 6) 使 Http.sys 使用 Windows 身份验证 - Make Http.sys work with Windows Authentication 这可能是由于在 HTTPS 案例中未使用 HTTP.SYS 正确配置服务器证书。 c# - This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. c# 为什么 HttpListener 在侦听强通配符 (http://+:port) http.sys/urlacl 绑定时“与现有注册冲突”? - Why does HttpListener “conflict with an existing registration” when listening to a Strong Wildcard (http://+:port) http.sys/urlacl binding?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM