简体   繁体   English

使用Express时如何在Node.js中设置maxSockets?

[英]How do you set maxSockets in Node.js when using Express?

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

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,开发人员和操作系统可以控制应用程序可以保持对给定主机开放的同时连接数。

Node v0.12.0 (Stable) release notes 节点v0.12.0(稳定)发行说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当达到maxSockets时,node.js会发生什么? - node.js what happens when maxSockets are reached? 你如何模块化Node.JS w / Express - How do you modularize Node.JS w/Express 你如何在不使用 node.js、express 或构建工具的情况下使用 Threejs? - how do you use threejs WITHOUT using node.js, express, or a build tool? 如何使用 Node.js 在集群中设置工作人员而不将其放在同一个文件中? - How do you set up workers in a cluster using Node.js without having it in the same file? 不尊重Node.js http.globalAgent.maxSockets - Node.js http.globalAgent.maxSockets not respected 在Javascript中(使用node.js时),您如何知道/定义变量的范围? - In Javascript (when using node.js), how do you know/define the scope of variables? 使用 Node JS/Express 计算 REST API 的方程时,如何限制输入负数? - How do you restrict inputting negative numbers when calculating equations for REST API using Node JS/Express? 如何在VPS上找到node.js Express网站的URL? - How do you find the url for a node.js express site on a VPS? 如何设置可在所有路由express / node.js中访问的全局变量 - How do I set a global variable accessible throughout all routes express/node.js 当用户加入并离开使用discord.js + node.js时,如何更新firebase数据库 - How do you update the firebase database when a user joins and leaves using discord.js + node.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM