-
Notifications
You must be signed in to change notification settings - Fork 211
Open
Description
Issue type
- bug
Brief description
Hi, I'm using Bitfinex websockets, and when there is a 429 error code, it throw an exception which is impossible to catch, and my process is killed.
I wrapped all the relative bitfinex-api-node
code in a huge try/catch
but it still impossible...
My code
try {
const candleKey = this.formatCandleEndpoint();
this.wsSocket = new WSv2({ transform: true, autoReconnect: true });
this.wsSocket.once(
'error',
error => Logger.error(
`error bitfinex candle socket for: ${this.pair} ${this.interval}`,
error.toString(),
),
);
this.wsSocket.once(
'close',
() => {
Logger.log(`Bitfinex candle socket for: ${this.pair} ${this.interval} closed`);
},
);
this.wsSocket.once('open', async () => {
const symbol = this.formatPair();
this.wsSocket.onCandle({ key: candleKey }, candles => {
this.lastCandle = candles[0];
});
const subscribeCandle = await asyncWrap(this.wsSocket.subscribeCandles(candleKey));
if (subscribeCandle.error) {
Logger.error(
`Unable to subscribe on Bitfinex candle socket for: ${this.pair} ${this.interval}`,
subscribeCandle.error.toString(),
);
}
});
const openCandleSocket = await asyncWrap(this.wsSocket.open());
if (openCandleSocket.error) {
Logger.error(
`Unable to open Bitfinex candle socket for: ${this.pair} ${this.interval}`,
openCandleSocket.error.toString(),
);
}
} catch (error) {
Logger.error(
`Bitfinex candle socket on ${this.pair} ${this.interval} throw an error`,
error.toString(),
);
this.restartOnError();
}
Metadata
Metadata
Assignees
Labels
No labels