Check if socket is already connected in _openSocket(). Fixes https://github.com/webtorrent/webtorrent/issues/1245.

This commit is contained in:
Eric Guan 2019-08-14 14:20:18 -07:00
parent 5b9da4a5e2
commit fc2f84ad60

View File

@ -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