Better status during reconnection.

This commit is contained in:
Julien Fontanet
2015-02-11 15:11:03 +01:00
parent c6d779853a
commit c80f6e8285

View File

@@ -211,7 +211,9 @@ var objectsOptions = {
function tryConnect() {
/* jshint validthis: true */
this.status = 'connecting';
return this._api.connect().bind(this).catch(function () {
this.status = 'disconnected';
var delay = this._backOff.next().value;
return Bluebird.delay(delay).bind(this).then(tryConnect);
});
@@ -250,7 +252,6 @@ function connect() {
return this._connection;
}
this.status = 'connecting';
this._connection = tryConnect.call(this).then(
onSuccessfulConnection, onFailedConnection
);