我有一个 Angular 应用程序,它通过 httpClient 模块与 Node.JS 服务器通信。 似乎每次向服务器发送 post 请求时,它们都会创建一个新的套接字连接。我想使用一个套接字连接来处理多个请求。
- http 请求每次发送到服务器时都会创建新的套接字连接吗?
- 如何在 Angular httpClient 中通过一个套接字连接发出多个请求?
最佳答案
据我所知,如果不修改浏览器/通过插件,这是不可能的。
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.
ResourceDispatcherHost
从套接字池中分配可用套接字...
the browser is able to enforce limits on the number of open sockets
关于javascript - 如何在 Angular httpClient 中通过一个套接字连接发出多个请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57421687/