Giter VIP home page Giter VIP logo

node1000k's Issues

使用单个服务报EADDRNOTAVAIL错误

使用你的脚本执行完后,connection count 在392700导致了core dumped.
然后我对脚本进行了修改,因为想试一下如果只起单个服务的话能有多少个连接,所以将代码改为如下:

var net = require('net');
var count = 0
//server
let server = net.createServer(function(conn){
    conn.on("close", function(code, reason){
        console.log("close", code, reason);
    })
    conn.on("error", function(code, reason){
        console.log("error close", code, reason);
    })
}).listen({port : 8080, host: "0.0.0.0", backlog: 100000}).on("connection", _=>{count++});

//client
setInterval(_=>{new Array(300).fill(1).map((_,index)=>index+1926).map(p=>{
    new net.Socket().connect(8080,'127.0.0.1')
        .on('error',function(e){
            console.log(count);
            console.log(e);
            process.exit()}
        );
    })&&console.log('connection count:',count)},100)

结果在connection count 达到64500的时候报了如下错误

{ Error: connect EADDRNOTAVAIL 127.0.0.1:8080 - Local (127.0.0.1:0)
    at internalConnect (net.js:872:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:294:19)
    at defaultTriggerAsyncIdScope (net.js:962:9)
    at process._tickCallback (internal/process/next_tick.js:61:11)
  errno: 'EADDRNOTAVAIL',
  code: 'EADDRNOTAVAIL',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8080 }

原因应该是端口被耗尽,但是multiple server 不应该也会有这样的问题吗?
想请教下为什么multiple server和single server会有这样的差距?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.