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

前端 未结 2 2076
悲&欢浪女
悲&欢浪女 2021-02-02 12:27

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

2条回答
  •  半阙折子戏
    2021-02-02 12:30

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

    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;
    

提交回复
热议问题