node.js - Nodejs Binance ws message const { WebsocketClient } = require('binance'); - Stack Overflow

I am using Binance Node.js API and websocket, but I always getthe message'Completed keep alive cy

I am using Binance Node.js API and websocket, but I always getthe message

'Completed keep alive cycle for listenKey(TZbi36E773J4pVkD8ZacgrnAhQ9YlvR82q50lw6z9Nno89WIni8K0d65xXfE) in market(spot)',
   {
    category: 'binance-ws',
    listenKey: 'TZbi36E773J4pVkD8ZacgrnAhQ9YlvR82q50lw6z9Nno89WIni8K0d65xXfE'
  }
 ]

How can I get rid of that? I want to print only my own logs the I call myself using colsole.log('blabla') to the console.

I use it like this

const { WebsocketClient } = require('binance');
const wsClient = new WebsocketClient(
  {
    api_key: key,
    api_secret: secret,
    beautify: true,
    // Disable ping/pong ws heartbeat mechanism (not recommended)
    // disableHeartbeat: true
  },
);


...
...
...

wsClient.on('message', (data) => {
  //bla bla
}

I am using Binance Node.js API and websocket, but I always getthe message

'Completed keep alive cycle for listenKey(TZbi36E773J4pVkD8ZacgrnAhQ9YlvR82q50lw6z9Nno89WIni8K0d65xXfE) in market(spot)',
   {
    category: 'binance-ws',
    listenKey: 'TZbi36E773J4pVkD8ZacgrnAhQ9YlvR82q50lw6z9Nno89WIni8K0d65xXfE'
  }
 ]

How can I get rid of that? I want to print only my own logs the I call myself using colsole.log('blabla') to the console.

I use it like this

const { WebsocketClient } = require('binance');
const wsClient = new WebsocketClient(
  {
    api_key: key,
    api_secret: secret,
    beautify: true,
    // Disable ping/pong ws heartbeat mechanism (not recommended)
    // disableHeartbeat: true
  },
);


...
...
...

wsClient.on('message', (data) => {
  //bla bla
}
Share Improve this question edited Mar 27 at 9:03 Mureinik 313k54 gold badges364 silver badges393 bronze badges asked Mar 4 at 11:14 SunnyBeachTaxiSunnyBeachTaxi 251 silver badge3 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You can override the logger and have the lower log levels (or all of them) do nothing:

const { WebsocketClient, DefaultLogger } = require('binance');
const doNothing = (...params) => {};
const logger = {
    ...DefaultLogger,
    silly: doNothing,
    debug: doNothing,
    notice: doNothing,
    info: doNothing
};
const wsClient = new WebsocketClient(
  {
    api_key: key,
    api_secret: secret,
    beautify: true
  },
  logger
);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745047799a4608201.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信