使用Express时如何在Node.js中设置maxSockets? [英] How do you set maxSockets in Node.js when using Express?

查看:668
本文介绍了使用Express时如何在Node.js中设置maxSockets?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Express框架时是否有办法修改Node.js maxSockets 设置?

Is there a way to modify the Node.js maxSockets setting when using the Express framework?

推荐答案

在某处执行 var http = require('http'),只需添加 http.globalAgent.maxSockets = x (其中'x'是您想要的套接字数量)。

Somewhere after you do var http = require('http'), just add http.globalAgent.maxSockets = x (where 'x' is the number of sockets you want).

请注意,如果您通过https提出请求,则还需要为https设置maxSockets。

Please note that if you are making requests over https, you will need to set maxSockets for https as well.

var https = require('https');
https.globalAgent.maxSockets = your_val_here;

这篇关于使用Express时如何在Node.js中设置maxSockets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆