Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

429 error exception thrown break everything #568

Open
1 task done
Johann-S opened this issue Jan 11, 2021 · 2 comments
Open
1 task done

429 error exception thrown break everything #568

Johann-S opened this issue Jan 11, 2021 · 2 comments

Comments

@Johann-S
Copy link

Johann-S commented Jan 11, 2021

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...

image

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();
}
@shortthefomo
Copy link

yup same thing

@shortthefomo
Copy link

here is my stack trace... same issue we have removed bitinex till the socket issue is resolved as it kills the entier stack.

`Error: Unexpected server response: 503
at ClientRequest. (/Users/lathan/Sites/ripple/xrpl-rosetta/node_modules/ws/lib/websocket.js:616:7)
at ClientRequest.emit (node:events:394:28)
at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:621:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:127:17)
at TLSSocket.socketOnData (node:_http_client:487:22)
at TLSSocket.emit (node:events:394:28)
at addChunk (node:internal/streams/readable:312:12)
at readableAddChunk (node:internal/streams/readable:287:9)
at TLSSocket.Readable.push (node:internal/streams/readable:226:10)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
1006
Reconnecting: bitfinex
node:events:371
throw er; // Unhandled 'error' event
^

Error: Unexpected server response: 503
at ClientRequest. (/Users/lathan/Sites/ripple/xrpl-rosetta/node_modules/ws/lib/websocket.js:616:7)
at ClientRequest.emit (node:events:394:28)
at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:621:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:127:17)
at TLSSocket.socketOnData (node:_http_client:487:22)
at TLSSocket.emit (node:events:394:28)
at addChunk (node:internal/streams/readable:312:12)
at readableAddChunk (node:internal/streams/readable:287:9)
at TLSSocket.Readable.push (node:internal/streams/readable:226:10)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
Emitted 'error' event on WebSocket instance at:
at abortHandshake (/Users/lathan/Sites/ripple/xrpl-rosetta/node_modules/ws/lib/websocket.js:743:15)
at ClientRequest. (/Users/lathan/Sites/ripple/xrpl-rosetta/node_modules/ws/lib/websocket.js:616:7)
[... lines matching original stack trace ...]
at TLSSocket.Readable.push (node:internal/streams/readable:226:10)`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants