From ca2839594e8ac90a27510a221dc05aa809826491 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sat, 9 May 2020 16:36:33 +0200 Subject: [PATCH] Timeout quikly when disconnecting existing slave If a slave that is already connected attempts connecting the existing connection for that slave is disconnected. The most common scenario for this is that the existing connection is stale and the slave is attempting to connect agan. However if the connection is stale then the disconnection will take 15 minutes to time out and the slave will appear unresponsive during this time. Fix this problem by setting the timeout to 15 seconds before disconnecting the existing connection. --- master.js | 1 + 1 file changed, 1 insertion(+) diff --git a/master.js b/master.js index 8dc6b9dc..2617cf59 100644 --- a/master.js +++ b/master.js @@ -1006,6 +1006,7 @@ async function handleHandshake(message, socket, req, attachHandler) { let connection = slaveConnections.get(data.id); if (connection) { console.log(`SOCKET | disconnecting existing connection for slave ${data.id}`); + connection.connector.setTimeout(15); // Slave connection is likely stalled await connection.disconnect(1008, "Registered from another connection"); }