I have been setting the ServicePoint.ConnectionLeaseTimeout
property when my web API starts up so that connections are refreshed regularly for load balancing scenarios by using ServicePointManager.FindServicePoint
. But, I am finding that at some time after using HTTP connections for the ServicePoint the ServicePoint.ConnectionLeaseTimeout
has changed from my set value to the default -1.
I am definitely not setting the ServicePoint.ConnectionLeaseTimeout
to -1 anywhere in my code and the other service points that I have configured, which have not been used for any connections are still at the configured value.
So, I must assume that the ServicePoint that I originally configured has been disposed of and replaced with a new ServicePoint object where the ServicePoint.ConnectionLeaseTimeout
property has the default value.
I know that ServicePoints can be deleted when ServicePointManager.MaxServicePoints
is exceeded, but in my application ServicePointManager.MaxServicePoints
is set to 0 (unlimited).
I'm also aware that the ServicePoint may be disposed after ServicePointManager.MaxServicePointIdleTime
is exceeded, but I am setting it to int.MaxValue (~25 days) and that time has definitely not passed.
Does anyone have any other information on how the lifecycle of ServicePoint is managed and how to better manage the configuration of a ServicePoint (in particular ConnectionLeaseTimeout) without simply finding the ServicePoint at application start up and setting it once?