Variance and higher max

This commit is contained in:
Diego Rodríguez Baquero 2016-03-16 01:14:24 -03:00
parent 529203ea40
commit 050d95ac72

View File

@ -16,8 +16,8 @@ var Tracker = require('./tracker')
var socketPool = {}
var RECONNECT_MINIMUM = 15 * 1000
var RECONNECT_MAXIMUM = 5 * 60 * 1000
var RECONNECT_RETRY = 30 * 1000
var RECONNECT_MAXIMUM = 30 * 60 * 1000
var RECONNECT_VARIANCE = 30 * 1000
var OFFER_TIMEOUT = 50 * 1000
inherits(WebSocketTracker, Tracker)
@ -236,7 +236,7 @@ WebSocketTracker.prototype._onSocketError = function (err) {
WebSocketTracker.prototype._startReconnectTimer = function () {
var self = this
var ms = Math.min(RECONNECT_MINIMUM + (self.retries * RECONNECT_RETRY), RECONNECT_MAXIMUM)
var ms = Math.floor(Math.random() * RECONNECT_VARIANCE) + Math.min(Math.pow(2, self.retries) * RECONNECT_MINIMUM, RECONNECT_MAXIMUM)
self.reconnecting = true
var reconnectTimer = setTimeout(function () {