I would like to disable the Nagle algorithm on a specific connection (in my case, on the ElasticSearch server).
My code currently looks something like this:
ServicePointManager.FindServicePoint(new Uri(uriWithoutLocalPath)).UseNagleAlgorithm = false;
The problem is that the object is ServicePointprocessed after some time, which leads to its loss. Therefore, I can’t just run this code once, at system startup. It seems that I have several options in front of me:
- Globally disable the Nagle algorithm (hence affecting connections that I don't want to influence).
- Increase MaxServicePointIdleTime so it
ServicePointnever gets recycled (maybe a bad idea? My intuition tells me that). - Set some kind of timer that resets properties every N seconds, where N is less than the reuse time for
ServicePoint. - Reset properties every time I use a connection.
I don’t like any of these parameters, they either affect other things in the system, or they seem too complicated for what I want to do (for example, the timer option). It seems to me that there should be a simple solution. Ideas?
source
share