agent.maxSockets 到底是什么意思?
What does agent.maxSockets really mean?
agent.maxSockets 上的官方 doc 说它表示我的 http(s) 服务器可以有多少并发套接字的限制。所以我用 http.globalAgent.maxSockets set to 5
做了一些测试,我预计我只能有 5 个打开的 websockets。但事实证明我可以有超过 50 个打开的 websockets。
谁能解释一下 agent.maxSockets 的真正含义?
http.Agent
实例用于 出站 http 客户端(例如通过 http.request()
), 非入站 客户端变成 http.Server
。因此,如果您要使用 http.Agent
且 maxSockets
设置为 5 且 http.request()
,那么在任何给定时间最多只有 5 个连接到特定服务器的套接字。
agent.maxSockets 上的官方 doc 说它表示我的 http(s) 服务器可以有多少并发套接字的限制。所以我用 http.globalAgent.maxSockets set to 5
做了一些测试,我预计我只能有 5 个打开的 websockets。但事实证明我可以有超过 50 个打开的 websockets。
谁能解释一下 agent.maxSockets 的真正含义?
http.Agent
实例用于 出站 http 客户端(例如通过 http.request()
), 非入站 客户端变成 http.Server
。因此,如果您要使用 http.Agent
且 maxSockets
设置为 5 且 http.request()
,那么在任何给定时间最多只有 5 个连接到特定服务器的套接字。