简体   繁体   中英

How make http.globalAgent.maxSockets works on expressjs?

I see number of posts on this platform giving the same solution which does not work for me, so here is my very simple node program I would like to understand why it still appears to process requests 6 by 6 instead of what I setup in http.globalAgent.maxSockets ?

var http = require('http');

http.globalAgent.maxSockets = 10;

var express = require('express');

var app = express();

app.use('/', function(req, res, next){
    console.log('Request /');

    setTimeout(function(){
        res.send('ok');
        console.log('Handled');
    }, 2000);
});

app.listen(3309);

console.log('Server up.');

Thank you very much...

目前尚不清楚您尝试解决什么问题,但是http.globalAgent是单例http 客户端 ,因此它不会以任何方式影响您的代码。

Ok, my problem was the client used to execute request: Google Chrome Chrome has a 6 connexion per host limitation. So neither node/angular or some other framework is concerned by this issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM