diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-03-29 04:14:17 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-03-29 04:14:17 +0300 |
commit | 5360418d2a331f0cf00bcf1cf6dc819758f6aa17 (patch) | |
tree | c895ab0fb179e2178fa600aadc4d77f203ae0a05 /lib/peer.js | |
parent | e4d30a99136c0ae6eb2611bf6e7097e22ccc7fd6 (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.js | 5 |
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() } |