Max reconnect time

This commit is contained in:
Diego Rodríguez Baquero 2016-03-11 15:26:55 -03:00
parent 8e2dbdc576
commit 529203ea40

View File

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