Closed MauriPastorini closed 5 years ago
You are likely doing calls other than depthCache to cause this. The ETIMEDOUT error typically triggers when you send too many requests to Binance in a short amount of time and get temporarily banned by their loadbalancer for a short time.
If you are using the depth
function then it downloads a complete snapshot of the order book, so if that is the case you will need to delay your calls to depth
by 350ms each.
Hi jaggedsoft, thank you for your response. But I am not doing too many request, I am running only the script below and throws me that error. Also, I tried opening websockets manually for all the symbols as I tried with this library, and I could connect successfully, but again, not with the library
Here is the code:
const binance = require("node-binance-api")();
console.log("Starting");
binance.exchangeInfo(function(error, data) {
if (error) {
console.error("Error getting exchange information of Binance: ", error);
return;
}
let symbols = [];
for (let obj of data.symbols) {
symbols.push(obj.symbol);
}
binance.websockets.depthCache(
symbols,
(symbol, depth) => {
console.log("Depth cache: ", depth);
},
5
);
});
Error:
node-binance-api\node-binance-api.js:1771
if (err) throw err;
^
Error: ETIMEDOUT
at Timeout._onTimeout (G:\....\node_modules\request\request.js:849:19)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5)
Odd, that code is working fine for myself and countless others. I couldn't even begin to think why this would happen. Check out this code which connects to the websocket endpoints without using this library: https://github.com/jaggedsoft/node-binance-api/blob/master/examples/experiments.js
Yes this is very odd. I tried that example and it is working great and opening the websockets manually works great too.
Same thing happens to me with around 200 symbols. Works fine with 10-20 @jaggedsoft
Title
code
Symbols is the array with all the symbols ['ETHBTC',.....] Result
thank you