[英]How do you set maxSockets in Node.js when using Express?
Somewhere after you do var http = require('http')
, just add http.globalAgent.maxSockets = x
(where 'x' is the number of sockets you want). 在你做var http = require('http')
之后的某个地方,只需添加http.globalAgent.maxSockets = x
(其中'x'是你想要的套接字数)。
Please note that if you are making requests over https, you will need to set maxSockets for https as well. 请注意,如果您通过https发出请求,则还需要为https设置maxSockets。
var https = require('https');
https.globalAgent.maxSockets = your_val_here;
From version v0.12.0 maxSockets set to Infinity 从版本v0.12.0 maxSockets设置为Infinity
maxSockets are no longer limited to 5. The default is now set to Infinity with the developer and the operating system given control over how many simultaneous connections an application can keep open to a given host. maxSockets不再限于5.默认设置现在设置为Infinity,开发人员和操作系统可以控制应用程序可以保持对给定主机开放的同时连接数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.