Closed josbert-m closed 5 months ago
As a temporary fix join them yourself and pass one string to subscribe
@abanchev It's done, I did it as follows:
streamClient.subscribe([
`${symbols[0]}@kline_${Interval['1m']}`,
symbols.slice(1).map((s) => `${s}@kline_${Interval['1m']}`).join('/')
]);
@abanchev It's done, I did it as follows:
streamClient.subscribe([ `${symbols[0]}@kline_${Interval['1m']}`, symbols.slice(1).map((s) => `${s}@kline_${Interval['1m']}`).join('/') ]);
You can just do
streamClient.subscribe( symbols.map((s) => `${s}@kline_${Interval['1m']}`).join('/') );
This issue has been fixed in the latest release.
I'm encountering an error with the Binance Websocket Stream library
I'm working with code that utilizes the @binance/connector-typescript library to establish a Websocket connection to the Binance exchange and subscribe to kline (candlestick) data streams for specific symbols (btcusdt, bnbusdt, xrpusdt). However, I'm encountering an error when subscribing to multiple streams.
Code Snippet:
Error Message:
Expected Behavior:
The code should construct a URL for the Websocket subscription in the following format (without commas separating streams):
Problem:
The current implementation generates a URL with commas between the streams, which appears to be causing the server to return an error (status code 400, indicating a bad request).
Possible Causes:
I think the problem is in the following line:
https://github.com/binance/binance-connector-typescript/blob/e2edefaf9a54fcf87529c840633b5b4d1b8d7226/src/websocketStream.ts#L23
Maybe it should be: