最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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
);
发布评论

评论列表(0)

  1. 暂无评论