0

I have a window service which uses System.Threading.Timer to call a endpoint at a specific configured interval. I have say 10 instance timers configured to call the same endpoint at the same interval (say 10 seconds). If the HTTP endpoint takes longer time to finish, other my timers events are not fired. The other timers are fired after the http call returns. At anypoint in time only two timers are triggered concurrently and runs the handler code. During the execution of the handler code none of the other timers trigger.

To be precise only 2 timers are running concurrently. I am using .net framework 4.8

I will not be able to post the code here since it is a legacy proprietary code

1 Answers1

0

I have found the reason for this behavior in .net framework, there is a default on the number of connection you can open in to a endpoint. ServicePointManager.DefaultConnectionLimit set this limit to 2 for non web application. Since my code run as windows service it is limited to 2. You can override this behaviour by setting

Uri atmos = new Uri("http://endpoint");
ServicePoint sp = ServicePointManager.FindServicePoint(atmos);
sp.ConnectionLimit = 64;

or you can specify the setting in config file <system.net> <connectionManagement> <add address="**http://endpoint**" maxconnection="**64**"/> </connectionManagement> </system.net>

--experts from msdn-- The maximum number of concurrent connections allowed by a ServicePoint object. The default connection limit is 10 for ASP.NET hosted applications and 2 for all others. When an app is running as an ASP.NET host, it is not possible to alter the value of this property through the config file if the autoConfig property is set to true. However, you can change the value programmatically when the autoConfig property is true. Set your preferred value once, when the AppDomain loads.

https://learn.microsoft.com/en-us/dotnet/api/system.net.servicepointmanager.defaultconnectionlimit?view=netframework-4.8

Thanks to everyone who replied to this question.