1

I am trying to generate lot of requests from my angularjs app to a backend rest server. I am using http service to make the calls. I want to control the concurrency of requests going to server. I know that browser itself throttles the number of connetions per server.

Now my questions are:

  1. How can I control the number of connections chrome opens to a server? How to do it using angularjs?

  2. How does the angularjs http service works? Does it opens and close the http connection every time I make a http call? If yes then how can I create persistent connections in angularjs?

CoMpLeXiTy
  • 19
  • 3
  • Unless you just want a list of yes or no answers, i suggest rewording your questions and possibly splitting it into multiple separate questions. Asking "is it possible" will almost always be yes if you aren't specific enough. 1: Yes. 2: XMLHttpRequest is used. Yes. Yes. – Kevin B Feb 10 '15 at 19:57
  • Changed :). Can you explain your answer now ? – CoMpLeXiTy Feb 11 '15 at 05:34
  • You say you ***want*** to generate a lot of requests, I assume that is for testing purposes. If you just want your app to be able to communicate a lot of messages to the server you might want to look at something like SignalR or WebSockets. – Jason Goemaat Feb 11 '15 at 05:49

1 Answers1

0

XMLHttpRequest is used under the hood. Since it uses HTTP, most of the answers to your questions are dependent on the headers you use and the server you are communicating with. For instance, whether or not connections persist depend on whether or not Keep-Alive is specified and the server supports it.

As for the number of connections, this is generally limited by the browser on a per domain basis. You won't be able to make use of more than the browser can allow, but you can probably write your own code to throttle it down if you so desire.

This question has good information about connection limits for the various browsers.

Community
  • 1
  • 1
Joe Enzminger
  • 11,110
  • 3
  • 50
  • 75