[英]Node.js http.globalAgent.maxSockets not respected
當注冊了response
事件的請求中止時,將不再遵守maxSockets
限制。 它似乎僅在響應包含一些數據時發生。
經過測試的版本: v4.1.1和v5.1.0
var http = require('http');
http.globalAgent.maxSockets = 3;
for (var i = 0; i < 100; i++) {
var request = http.get('http://127.0.0.1:8080', function () {
// just register a listener...
});
request.setTimeout(1000, function () {
console.log('T')
this.abort();
});
}
require('http').createServer(function (reqest, response) {
console.log('R');
response.end('hello');
}).listen(8080);
服務器輸出為:
$ node server.js
R
R
R
# 1s timeout here...
R
R
R
R
R
R
# 1s timeout here...
R
R
R
R
R
R
R
R
R
R
R
R
# 1s timeout here...
[...]
似乎每次將maxSockets
乘以2( maxSockets
等),即使其值沒有變化。 我原本希望是3人一組。
在這種情況下, 恢復響應(而不是中止請求)可以正常工作。
好吧,這是Node.js的錯誤 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.