tiagosiebler / binance

Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & browser support, integration tests, beautification & more.
MIT License
747 stars 266 forks source link

Checking for API calls happening in the background #292

Closed skliarovartem closed 1 year ago

skliarovartem commented 1 year ago

Is lib making some request sometimes in background? I mean besides disableTimeSync option? I use rate limiter and sometimes I go over limits in 1-3 wights. So one of my suggestions is that your lib making some request to "/api/..." sometimes. Thanks!

tiagosiebler commented 1 year ago

Are you using the user data stream (in the websocket client)? It has to send a request to fetch a listen key when first opening the user data stream, and every 50 minutes it needs to send a listen-key keep alive request. If the user data stream disconnects for whatever reason, it'll first fetch a listen key via API call before reopening the stream - every time - to ensure the previously known listen key remains valid.

The only other timers in the ws client are for sending upstream events (ping frames), which I don't think would count towards this....maybe opening a new connection might?

In terms of REST client alone, disableTimeSync is true by default (so no time api calls should be happening by default). That's the only interval/timer in the REST client (can search for setInterval to see where it's created in the base rest client).

That's the only two places, assuming you're on the latest version (or one where this was still the case).

If you want to trace any calls happening from the client, it uses axios so you can set a request interceptor and log every request. Something like this:

import axios from 'axios';
axios.interceptors.request.use((request) => {
  console.log(new Date(), 'Starting Request', JSON.stringify(request, null, 2));
  return request;
});