From 1f681ed810663e808f32a864bc56cf556b4f6fcf Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Tue, 4 Aug 2015 21:45:46 +0200 Subject: [PATCH 1/2] add keepAlive option in createServer --- src/createServer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/createServer.js b/src/createServer.js index e4a459e..13fc54a 100644 --- a/src/createServer.js +++ b/src/createServer.js @@ -26,6 +26,8 @@ function createServer(options) { // and returning a modified response object. var beforePing = options.beforePing || null; + var enableKeepAlive = options.keepAlive == null ? true : options.keepAlive; + var serverKey = ursa.generatePrivateKey(1024); var server = new Server(options); @@ -194,7 +196,7 @@ function createServer(options) { client.write(0x02, {uuid: client.uuid, username: client.username}); client.state = states.PLAY; loggedIn = true; - startKeepAlive(); + if(enableKeepAlive) startKeepAlive(); clearTimeout(loginKickTimer); loginKickTimer = null; From 0ce00f2cc76fee5cdb93b4ad018c6549e38cb8c2 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 8 Aug 2015 17:29:54 +0200 Subject: [PATCH 2/2] put keepAlive: false in proxy.js : fix connecting to a proxy with some lag (ie not with both proxy and vanilla client in localhost) --- examples/proxy/proxy.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/proxy/proxy.js b/examples/proxy/proxy.js index ed628a8..39515a1 100644 --- a/examples/proxy/proxy.js +++ b/examples/proxy/proxy.js @@ -77,7 +77,8 @@ if(host.indexOf(':') != -1) { var srv = mc.createServer({ 'online-mode': false, - port: 25566 + port: 25566, + keepAlive: false }); srv.on('login', function(client) { var addr = client.socket.remoteAddress; @@ -101,7 +102,8 @@ srv.on('login', function(client) { port: port, username: user, password: passwd, - 'online-mode': passwd != null ? true : false + 'online-mode': passwd != null ? true : false, + keepAlive:false }); var brokenPackets = [/*0x04, 0x2f, 0x30*/]; client.on('packet', function(packet) {