Подключить EADDRNOTAVAIL localhost:8000

Я тестирую трафик на своем node приложение в localhost с помощью http.get(), я генерирую 10000 запросов каждые 5 секунд.

проблема в том, когда я запускаю команду npm start и через 20-30 секунд сервер рухнул и со следующей ошибкой

events.js:136
      throw er; // Unhandled 'error' event
      ^

Error: connect EADDRNOTAVAIL localhost:8000 - Local (localhost:0)
    at Object._errnoException (util.js:999:13)
    at _exceptionWithHostPort (util.js:1020:20)
    at internalConnect (net.js:987:16)
    at net.js:1087:9
    at process._tickCallback (internal/process/next_tick.js:150:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@1.0.0 start: `node ./bin/run`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the app@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kd/.npm/_logs/2018-03-28T08_32_26_105Z-debug.log

я использую 16.04.1-Ubuntu

вот мой app.js

var rob = require('./test/rob.js');
for (var i = 0; i < 10000; i++) {
    rob.init();
}

вот rob.js

var http = require('http');
module.exports = {
    init : function(){
        var pages = [
            'dashboard',
            'home',
            'login',
            'contact',
            'support',
            'about'
        ];
        setInterval(function(){
            try{
                var pg =  pages[Math.round(Math.random() * 5)];
                http.get('http://localhost:8000/' + pg,
                    res => {
                        console.log('RES =>','SUCCSESS');
                    },
                    err => {
                        console.log('ERROR','ERROR');
                    });
            }catch(err){
                console.log('ER','ERR');
            }
        },5000);
    }
}

вот run.js

var http = require('http');
var app = require('../app');

/* Create Server */
var port = 8000;
var host = '0.0.0.0';
var server = http.createServer(app);
io = module.exports = require('socket.io').listen(server, {
    pingTimeout: 7000,
    pingInterval: 10000
});
io.set("transports", ["xhr-polling","websocket","polling"]);

server.listen(port,host,function(){
    log('server is running on ' + host +':'+port);
});

как решить эту проблему?

Есть ли другой способ проверить трафик?

0 ответов

Другие вопросы по тегам