I use binance tr api for my trading bot ; Some days my bot works perfectly and i get all data via websocket. Some days ( or sometimes ) bot cannot receive data.
I use Nodejs on window 11.
const wsgonder={"method":"SUBSCRIBE","params":["!miniTicker@arr@3000ms"]};
var alinacak={};
const ws = new WebSocket("wss://stream-cloud.binance.tr/stream");
ws.on('open', function open() {
ws.send(JSON.stringify(wsgonder));
});
ws.on("ping",(e)=>{
console.log(e.toString());
ws.pong();
})
var count=0;
ws.on("message", async function incoming(data) {
count++;
console.log(count)
})
For example : sometimes count stop at 20 , sometimes stop at 10… Sometimes works perfectly all day long.
What is your network topology? Are you using a VPN or any proxy server? Do you use a stable internet connection, and if yes have you encountered ever any issues with HTTP calls or any other websocket servers?
I dont use VPN or proxy .
I dont get any error on other websites that use websocket.
Sometimes it works all day long without any problems. I don’t understand why I don’t get any errors
Side note: you shouldn’t need to send pongs yourself. WebSocket normally has autoPong enabled, responding with pongs properly and promptly after receiving them. You might still want to log the pings to confirm they are received and processed.