NetEase / pomelo

A fast,scalable,distributed game server framework for Node.js.
http://pomelo.netease.com
MIT License
11.87k stars 2.9k forks source link

catch error "ECONNRESET" #760

Closed hikaru7641 closed 9 years ago

hikaru7641 commented 9 years ago

My game server:

When running , sometime server connector crash with uncaughtExceptionerror: "ECONNRESET".

My solution catch this error: Add event "error" for hybridsocket on hybridconnector.js

............
hybridsocket.on('disconnect', self.heartbeat.clear.bind(self.heartbeat, hybridsocket.id));
hybridsocket.on('closing', Kick.handle.bind(null, hybridsocket));
hybridsocket.on('error', function(error){
        console.log('hybridsocket error');
        console.dir(error);
    });
.....................

When add event error, i only see console log error and connector server not crash ;) "{ [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }"

Hope this help for somebody ^^.

hikaru7641 commented 8 years ago

Error "ECONNRESET" so Connector-server will crash, you try change code in pomelo/lib/hybridconnector.js:

this.tcpServer = net.createServer();
===>

// edit by nes
this.tcpServer = net.createServer(function(socket){
socket.on('error', function(err2) {
console.error('tcpServer ERROR:', err2);
});
});