From e4ead3eec603705f7f743936878363df0baa927a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A4=9A=E5=BF=97=E6=88=90?= Date: Mon, 7 May 2018 17:03:25 +0800 Subject: [PATCH] check the socket is connected or not when socket is going to connect. --- lib/Connection.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index 619862ff..83229d8c 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -283,11 +283,13 @@ Connection.prototype.connect = function() { socket.destroy(); }, config.connTimeout); - socket.connect({ - port: config.port, - host: config.host, - localAddress: config.localAddress - }); + if (isUndefinedOrNull(socket.remoteAddress)) { + socket.connect({ + port: config.port, + host: config.host, + localAddress: config.localAddress + }); + } }; Connection.prototype.serverSupports = function(cap) {