ViewBlock / binance-api-node

:chart: A complete and heavily tested wrapper with typings for the Binance API.
669 stars 504 forks source link

Proposal: Handle FetchError #347

Open bennycode opened 3 years ago

bennycode commented 3 years ago

Recently my application stopped working because the Binance API was under stress and failed to respond in time. Because of this "binance-api-node" failed with the following error:

FetchError: request to https://api.binance.com/api/v3/klines?interval=1m&endTime=1613606340000&limit=1000&startTime=1613001600000&symbol=BTCUSDT failed, reason: connect ETIMEDOUT 52.84.150.39:443 at ClientRequest. (/home/runner/work/lambot-1/lambot-1/node_modules/node-fetch/index.js:133:11)

It would be nice if we could add a retry mechanism. In my own projects (like coinbase-pro-node), I am using axios-retry which works very well. I think there is something similar for isomorphic-fetch. What's your thought on that, @balthazar?

balthazar commented 3 years ago

Yeah definitely could have that feature in considering the recent surge on Binance servers

hp8wvvvgnj6asjm7 commented 3 years ago

Thinking about adding a websocket status checker too.

bennycode commented 3 years ago

@hp8wvvvgnj6asjm7 the "binance-api-node" already uses the reconnecting-websocket package, so what would you like to add to check the WebSocket connection?