socket: Throttle reconnection attempts

Previously, if the user held down the enter button while the socket
was disconnected, the client would try to connect in a very tight
loop.  Now we throttle reconnection attempts to 1 per second.

(imported from commit 7b18260b992d5a34f3ea7925cf72b383f84bbabd)
This commit is contained in:
Zev Benjamin
2013-10-28 16:30:20 -04:00
parent a33640c7dd
commit 90d92814ca

View File

@@ -116,11 +116,11 @@ Socket.prototype = {
};
},
_do_reconnect: function Socket__do_reconnect() {
_do_reconnect: _.throttle(function Socket__do_reconnect() {
blueslip.info("Attempting socket reconnect.");
this._sockjs = new SockJS(this.url, null, {protocols_whitelist: this._supported_protocols});
this._setup_sockjs_callbacks(this._sockjs);
},
}, 1000),
_try_to_reconnect: function Socket__try_to_reconnect() {
var that = this;