Reconnect if connection fails
This commit is contained in:
@@ -67,6 +67,7 @@ module.exports = class WebsocketClient extends EventEmitter {
|
||||
}
|
||||
|
||||
async _connect() {
|
||||
try {
|
||||
if(this.readyState === READY_STATE_INITIAL) this.readyState = READY_STATE_CONNECTING;
|
||||
|
||||
const authParams = await this._authenticate();
|
||||
@@ -78,6 +79,10 @@ module.exports = class WebsocketClient extends EventEmitter {
|
||||
this.ws.on('message', this._wsMessageHandler.bind(this));
|
||||
this.ws.on('error', this._wsOnErrorHandler.bind(this));
|
||||
this.ws.on('close', this._wsCloseHandler.bind(this));
|
||||
} catch(err) {
|
||||
this.logger.error('Connection failed', err);
|
||||
this._reconnect(this.options.reconnectTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
async _authenticate() {
|
||||
|
||||
Reference in New Issue
Block a user