HTTP 503 cloud resource_error ai_generated true

System.Net.Http.HttpRequestException:主机的连接数限制已超出

System.Net.Http.HttpRequestException: The connection limit for the host was exceeded

ID: cloud/azure-app-service-connection-limit-exceeded

其他格式: JSON · Markdown 中文 · English
82%修复率
82%置信度
1证据数
2024-06-10首次发现

版本兼容性

版本状态引入弃用备注
Azure App Service Windows 2022 active
.NET 8.0 active

根因分析

Azure应用服务计划有默认连接限制(如每个实例300个),因扩展不足或长连接耗尽。

English

Azure App Service plan has a default connection limit (e.g., 300 per instance) that is exhausted due to insufficient scaling or long-lived connections.

generic

官方文档

https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs#connection-limits

解决方案

  1. Scale out the App Service plan to more instances (e.g., increase instance count from 1 to 3) to distribute connections
  2. Enable Always On in App Service settings to prevent idle connection drops and reduce churn
  3. Set `ServicePointManager.DefaultConnectionLimit = int.MaxValue` in Global.asax.cs to increase outbound connection limit (if error is outbound)

无效尝试

常见但无效的做法:

  1. 80% 失败

    This only affects outgoing HTTP connections; the error is about incoming connections to the App Service, not outbound.

  2. 90% 失败

    Restart resets connections temporarily but does not address the root cause; connections quickly rebuild and exceed the limit again.

  3. 70% 失败

    Disabling keep-alive may increase connection churn and worsen the issue, as each request opens a new connection.