Hi , i’m trying to construct a local futures orderbook(depth1, only need best ask,bid) through btcusdt@bookTicker stream.
To monitor the time gap between the real bookdata and the received time, i’m tracking the timediff.
timediff = +new Date() - data.data.T;
At first, average time differences are below 5~10ms but within few minutes it quickly increases to 8000ms~500000ms that i absolutely can’t use those info at trading . sometimes it goes back to normal, but usually it persists like that.
i’m answering to the ping/pong stream and using AWS Tokyo region EC2 t2 with ubuntu+nodejs.
Is there any additional action that i should do to keep my websocket connection without the insane delays?
With same code, upbit and bithumb exchanges’ ws connections are maintained properly.
i’m attaching the partial code that i used to setup WS.
_setupWebSocket(eventHandler, path) {
if (this._sockets[path]) {
return this._sockets[path];
}
path = this._baseUrl + path;
const ws = new WebSocket(path);
this._sockets[path] = ws;
ws.on("ping", (data) => {
ws.pong("pong");
ws.isAlive = true;
ws.lastAlive = new Date();
});
ws.on("message", (message) => {
// logger.info(message);
let event;
try {
event = JSON.parse(message);
} catch (e) {
event = message;
}
if (this._beautify) {
if (event.stream) {
event.data = this._beautifyResponse(event.data);
} else {
event = this._beautifyResponse(event);
}
}
// logger.info(event);
eventHandler(event);
});
ws.on("error", (e) => {
logger.info(e);
// node.js EventEmitters will throw and then exit if no error listener is registered
});
return ws;
}
======
actual path stream i used:
wss://fstream.binance.com/stream?streams=btcusdt@bookTicker/ethusdt@bookTicker/bchusdt@bookTicker/xrpusdt@bookTicker/eosusdt@bookTicker/ltcusdt@bookTicker/trxusdt@bookTicker/etcusdt@bookTicker/linkusdt@bookTicker/xlmusdt@bookTicker/adausdt@bookTicker/xmrusdt@bookTicker/dashusdt@bookTicker/zecusdt@bookTicker/xtzusdt@bookTicker/bnbusdt@bookTicker/atomusdt@bookTicker/ontusdt@bookTicker/iotausdt@bookTicker/batusdt@bookTicker/vetusdt@bookTicker/neousdt@bookTicker/qtumusdt@bookTicker/iostusdt@bookTicker/thetausdt@bookTicker/algousdt@bookTicker/zilusdt@bookTicker/kncusdt@bookTicker/zrxusdt@bookTicker/compusdt@bookTicker/omgusdt@bookTicker/dogeusdt@bookTicker/sxpusdt@bookTicker/kavausdt@bookTicker/bandusdt@bookTicker/rlcusdt@bookTicker/wavesusdt@bookTicker/mkrusdt@bookTicker/snxusdt@bookTicker/dotusdt@bookTicker/yfiusdt@bookTicker/balusdt@bookTicker/crvusdt@bookTicker/trbusdt@bookTicker/yfiiusdt@bookTicker/runeusdt@bookTicker/sushiusdt@bookTicker/srmusdt@bookTicker/bzrxusdt@bookTicker/solusdt@bookTicker/icxusdt@bookTicker/storjusdt@bookTicker/blzusdt@bookTicker/uniusdt@bookTicker/avaxusdt@bookTicker/ftmusdt@bookTicker/enjusdt@bookTicker/flmusdt@bookTicker/tomousdt@bookTicker/renusdt@bookTicker/ksmusdt@bookTicker/nearusdt@bookTicker/aaveusdt@bookTicker/filusdt@bookTicker/rsrusdt@bookTicker/lrcusdt@bookTicker/maticusdt@bookTicker/oceanusdt@bookTicker/cvcusdt@bookTicker/belusdt@bookTicker/ctkusdt@bookTicker/axsusdt@bookTicker/alphausdt@bookTicker/zenusdt@bookTicker/sklusdt@bookTicker