Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2016-03-29 04:14:17 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-03-29 04:14:17 +0300
commit5360418d2a331f0cf00bcf1cf6dc819758f6aa17 (patch)
treec895ab0fb179e2178fa600aadc4d77f203ae0a05 /lib/peer.js
parente4d30a99136c0ae6eb2611bf6e7097e22ccc7fd6 (diff)
Shorter connect timeout for TCP peers
This restores the older timeout for TCP peers, which was originally increased as a workaround to give enough time for WebRTC peers. Supersedes https://github.com/feross/bittorrent-swarm/pull/21
Diffstat (limited to 'lib/peer.js')
-rw-r--r--lib/peer.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/peer.js b/lib/peer.js
index 70ab12b..cfa0cc5 100644
--- a/lib/peer.js
+++ b/lib/peer.js
@@ -3,7 +3,8 @@ var Wire = require('bittorrent-protocol')
var WebConn = require('./webconn')
-var CONNECT_TIMEOUT = 25000
+var CONNECT_TIMEOUT_TCP = 25000
+var CONNECT_TIMEOUT_WEBRTC = 5000
var HANDSHAKE_TIMEOUT = 25000
/**
@@ -206,7 +207,7 @@ Peer.prototype.startConnectTimeout = function () {
clearTimeout(self.connectTimeout)
self.connectTimeout = setTimeout(function () {
self.destroy(new Error('connect timeout'))
- }, CONNECT_TIMEOUT)
+ }, self.type === 'webrtc' ? CONNECT_TIMEOUT_WEBRTC : CONNECT_TIMEOUT_TCP)
if (self.connectTimeout.unref) self.connectTimeout.unref()
}