binance-exchange/node-binance-api

Websocket depthCache fails with exception

adityamertia opened this issue · 2 comments

Short Description:
Websocket depthCache fails with an exception

Platform:

  • linux

node version:

  • v10.5.0

Long descrption

  • Websocket depthCache fails with an exception

code

const Binance = require('node-binance-api');
const _SYMBOL_ = 'BTCUSDT';
const binance = new Binance().options({
  'APIKEY': process.env.BINANCE_API_KEY,
  'APISECRET': process.env.BINANCE_API_SECRET,
  'recvWindow': 60000,
  'useServerTime': true
});
binance.websockets.depthCache([_SYMBOL_], (symbol, depth) => {
  let bids = binance.sortBids(depth.bids);
  let asks = binance.sortAsks(depth.asks);
  async.parallel({
    binanceBids: function(callback) {
      console.log("binanceBids: " + JSON.stringify(bids));
      callback(null, 'done');
    },
    binanceAsks: function(callback) {
      console.log("binanceAsks: " + JSON.stringify(asks));
      callback(null, 'done');
    }
  }, function(err, results) {
    if (err) {
      throw err;
    } else {
      console.log("Result : " + JSON.stringify(results));
    }
  });
});

result

/home/ec2-user/aditya/node_modules/node-binance-api/node-binance-api.js:1747
                         if (err) throw err
                                  ^
[object Object]

thank you

What error are you getting? Can you read err.message? I believe this is related to binance being down right now

Yes looks like this was due to binance being down. However on older versions of the library i was getting null values(i tried in parallel) but in latest version the code failed. Ideally, the library should not crash if binance API/ws are down. This will still count as a bug in my opinion.