From fc2f84ad60cc881c12a263c4fa96419792b0f877 Mon Sep 17 00:00:00 2001 From: Eric Guan Date: Wed, 14 Aug 2019 14:20:18 -0700 Subject: [PATCH] Check if socket is already connected in _openSocket(). Fixes https://github.com/webtorrent/webtorrent/issues/1245. --- lib/client/websocket-tracker.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index 6f9e9e7..8a0f475 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -172,6 +172,9 @@ class WebSocketTracker extends Tracker { this.socket = socketPool[this.announceUrl] if (this.socket) { socketPool[this.announceUrl].consumers += 1 + if (this.socket.connected) { + this._onSocketConnectBound() + } } else { this.socket = socketPool[this.announceUrl] = new Socket(this.announceUrl) this.socket.consumers = 1