jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.58k stars 767 forks source link

Websockets timing out #82

Closed ryanvanbelkum closed 6 years ago

ryanvanbelkum commented 6 years ago

I'm trying to establish a websocket connection and consistently seeing a timeout error.

Ex:

binance.websockets.prevDay('BNBBTC', (error, response) => {
  console.log(response);
});

Outcome

Uncaught Error: connect ETIMEDOUT 13.112.109.76:9443

However, some of the streams are working as expected. Ex:

binance.websockets.depthCache(["BNBBTC"], function(symbol, depth) {

Is anyone else seeing this issue?

Here is my function

function setupWebsocks(){
  binance.options({
    APIKEY: "......",
    APISECRET: "......"
  });

  binance.websockets.prevDay('BNBBTC', (error, response) => {
    console.log(response);
  });
}
jaggedsoft commented 6 years ago

Are you passing multiple symbols to the function? If you pass too many at once, binance will block you for a short time. I'm working on an automatic solution for this

For now, I wait 150ms before opening another connection

ryanvanbelkum commented 6 years ago

@jaggedsoft Thank you for the quick reply. The issue is actually on my end (firewall). Closing.