Is it possible to combine HTTP connections?

For a C # web service that communicates with a limited set of other servers, I want to create 1 HTTP connection pool per server that I want to contact.

The basic concept, of course:

  • Each pool should open several connections (3 connections?) On its remote web server and keep these connections on the network.
  • The maximum lifetime should be used to reconfigure (disconnect / reconnect) to the remote web server, preventing the remote web server from disconnecting before we do this.
  • Connections should not be created at the same time, but with a small pause between 3 connections, so reuse also does not occur at the same time.
  • If the remote web server still shuts down unexpectedly, it should be noticed, and we should reconnect.
  • If reconnecting for any reason is not possible, retrying should be done after a short pause.

Thus, when I want to send HttpWebRequest, I have ready-to-use connections, eliminating the time it takes to establish a connection the moment I want to use it.

At the moment, I do not know if this is even a standard HttpWebRequest function. So sorry if I ask for this. Googling for this only led me to similar questions for Java.

Question 1: is there such a thing in .NET / C #?

Question 2: if not, is there a resource in this present on the Internet that you know about?

Question 3: if not, how to approach the construction itself?

+6
source share
1 answer

HttpWebRequest (which essentially means that all Http APIs in .net) already use pooling by default.

Take a look at ServicePoint and ServicePointManager if you need to manage any connection pool settings.

+3
source

All Articles