Node.js-运行多个请求时写入EPIPE错误

Node.js-运行多个请求时写入EPIPE错误,node.js,http,load-testing,stress-testing,epipe,Node.js,Http,Load Testing,Stress Testing,Epipe,我正在使用Node的“net”模块编写一个静态web服务器,在运行压力测试时遇到了一些问题 这是测试本身的代码: var http = require("http"); http.globalAgent.maxSockets = 100000; var numOfRequests = 1000; var options = { host: 'localhost', port: 9000, path: '/first/profile.html', method: 'GET' }

我正在使用Node的“net”模块编写一个静态web服务器,在运行压力测试时遇到了一些问题

这是测试本身的代码:

var http = require("http");
http.globalAgent.maxSockets = 100000;
var numOfRequests = 1000;

var options = {
  host: 'localhost',
  port: 9000,
  path: '/first/profile.html', 
  method: 'GET'
};



//Number of current responses.
var currResponse = 0;

//Create 1000 http requests 
for (var i = 0; i < numOfRequests; i++) {

    var req = http.request(options, function(res) {
        console.log("Got response: " + res.statusCode);
        console.log("response num: "+currResponse);
        currResponse++;

    });
    req.on('error',function(e){ console.log('some error occured: '+e.message); });
    req.end();
}
在节点v上运行时。0.8.15当前最新版本,对于大于20的'numOfRequest',服务器几乎崩溃-在1000个请求中,只有约160个得到正确处理。从测试人员的角度来看

我使用带有适当参数的fs.createReadStream.pipe,并输入{end:false}通过套接字发送数据。另外,我调用socket.destroy,其中socket是在两秒不活动超时时在net.createServer的回调函数中接收的参数,如果我接收到连接,则调用socket.end:在HTTP请求中作为头关闭


有什么帮助吗?我什么都试过了;切换到http.get,在创建服务器时放入{allowHalfOpen:true}等等,但仍然会出现错误:write EPIPE,或者,过了一会儿,错误:此套接字已关闭。从服务器端挂断,从客户端挂断套接字。

没关系,修复了它。我不知道到底是什么解决了这个问题,但也许删除了http.globalAgent.maxSockets=100000行;在管道之前添加if socket.writable对它做了些什么,尽管我不知道如何。。