javascript - 如何在 Angular httpClient 中通过一个套接字连接发出多个请求?

标签 javascript angular httpclient

我有一个 Angular 应用程序,它通过 httpClient 模块与 Node.JS 服务器通信。 似乎每次向服务器发送 post 请求时,它们都会创建一个新的套接字连接。我想使用一个套接字连接来处理多个请求。

  1. http 请求每次发送到服务器时都会创建新的套接字连接吗?
  2. 如何在 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/

相关文章:

javascript - bool 运算符求值顺序

javascript - javascript 将嵌套对象带到根级别

html - Angular,单击提交按钮后获取并显示提交时间

javascript - 确保下一个函数仅在对话框关闭后运行

javascript - 使用 JavaScript 检测脚本是否被阻止(通过 Web 过滤、防火墙等)

javascript - JQuery 函数作为单行工作,但当我将其分解时却不行

Angular 2 + OnPush : Change detection does not work on pouchdb callbacks

java - PoolingClientConnectionManager 性能问题

android - 如何在 Android 上的 DefaultHttpClient 中检查缓存

c# - 多个带有代理的 HttpClients,试图达到最大下载速度