Search code examples
javascriptangularhttpclient

How to make multiple requests over one socket connection in Angular httpClient?


I have an Angular app, it communicates with Node.JS server through httpClient module. Seems every time when it send post request to server, they create a new socket connection. I would like to use one socket connection for multiple request.

  1. Does http request create new socket connection every time when it is send to server?
  2. How to make multiple requests over one socket connection in Angular httpClient?

Solution

  • As far as I am aware, this is not possible without browser modification / through a plugin.

    https://www.igvita.com/posa/high-performance-networking-in-google-chrome/#ipc

    All communication between the renderer and the kernel process in Chrome is done via IPC. Each message from the renderer is serialized and passed to a dedicated I/O thread, which dispatches it to the kernel process. On the receiving end, the kernel process provides a filter interface, which allows Chrome to intercept resource IPC requests (see ResourceMessageFilter) which should be handled by the network stack.

    The resource filter runs in the I/O thread in the browser process, intercepts the resource request messages, and forwards them to a ResourceDispatcherHost singleton in the browser process.

    The ResourceDispatcherHost allocates to available sockets from the socket pool which...

    the browser is able to enforce limits on the number of open sockets