ServicePoint.ConnectionLeaseTimeout
当我的 Web API 启动时,我一直在设置该属性,以便使用ServicePointManager.FindServicePoint
. 但是,我发现在为 ServicePoint 使用 HTTP 连接后的某个时间,ServicePoint.ConnectionLeaseTimeout
它已从我的设置值更改为默认值 -1。我绝对没有ServicePoint.ConnectionLeaseTimeout
在我的代码中的任何地方将 -1 设置为 -1,而我配置的其他服务点(尚未用于任何连接)仍处于配置值。因此,我必须假设我最初配置的 ServicePoint 已被处置并替换为ServicePoint.ConnectionLeaseTimeout
属性具有默认值的新 ServicePoint 对象。
我知道超过时可以删除ServicePoints ServicePointManager.MaxServicePoints
,但在我的应用程序ServicePointManager.MaxServicePoints
中设置为0(无限制)。我也知道 ServicePoint 可能会在ServicePointManager.MaxServicePointIdleTime
超出后被处置,但我将其设置为 int.MaxValue (~25 天)并且那个时间肯定没有过去。
有没有人知道如何管理 ServicePoint 的生命周期以及如何更好地管理 ServicePoint 的配置(特别是 ConnectionLeaseTimeout),而无需在应用程序启动时简单地找到 ServicePoint 并设置一次?