Open usmane3 opened 4 years ago
Hi,
The following code produces the debug below:
const ReconnectingWebSocket = require('reconnecting-websocket'); const WebSocket = require('ws');
const options = { WebSocket: WebSocket, // custom WebSocket constructor connectionTimeout: 1000, maxRetries: 10, debug: true }; const rws = new ReconnectingWebSocket('wss://fstream.binance.com/stream/streams=btcusdt@trade',[], options);
rws.addEventListener('open', () => {
console.log('connection opened');
});
rws.addEventListener('message', (data) => {
console.log(data);
output=== RWS> connect 0 RWS> next delay 0 RWS> connect { url: 'wss://fstream.binance.com/stream/streams=btcusdt@trade', protocols: [] } RWS> addListeners RWS> timeout event RWS> error event TIMEOUT RWS> removeListeners RWS> exec error listeners RWS> connect 1 RWS> removeListeners RWS> next delay 1247.1575163718135 RWS> connect { url: 'wss://fstream.binance.com/stream/streams=btcusdt@trade', protocols: [] }...and so on
However this url works with
const WebSocket = require('ws');
const ws = new WebSocket('wss://fstream.binance.com/stream?streams=btcusdt@trade/ethusdt@trade');
ws.on('message', (data) => { if (data) { const trade = JSON.parse(data); // parsing single-trade record console.log(trade); } });
any ideas?
same issue
just found workaround here: https://github.com/Ashlar/binance-api-node/blob/master/src/open-websocket.js. Just curious - what's wrong with pong event?
Hi,
The following code produces the debug below:
const ReconnectingWebSocket = require('reconnecting-websocket'); const WebSocket = require('ws');
const options = { WebSocket: WebSocket, // custom WebSocket constructor connectionTimeout: 1000, maxRetries: 10, debug: true }; const rws = new ReconnectingWebSocket('wss://fstream.binance.com/stream/streams=btcusdt@trade',[], options);
rws.addEventListener('open', () => {
});
rws.addEventListener('message', (data) => {
});
output=== RWS> connect 0 RWS> next delay 0 RWS> connect { url: 'wss://fstream.binance.com/stream/streams=btcusdt@trade', protocols: [] } RWS> addListeners RWS> timeout event RWS> error event TIMEOUT RWS> removeListeners RWS> exec error listeners RWS> connect 1 RWS> removeListeners RWS> next delay 1247.1575163718135 RWS> connect { url: 'wss://fstream.binance.com/stream/streams=btcusdt@trade', protocols: [] }...and so on
However this url works with
const WebSocket = require('ws');
const ws = new WebSocket('wss://fstream.binance.com/stream?streams=btcusdt@trade/ethusdt@trade');
ws.on('message', (data) => { if (data) { const trade = JSON.parse(data); // parsing single-trade record console.log(trade); } });
any ideas?