Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v2.1.9): split subscription requests into batches of 20 #29

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

tiagosiebler
Copy link
Owner

Summary

Fixes error seen when attempting to subscribe to ±90 topics. Requests need to be split into batches of 20 per request.

import {
  DefaultLogger,
  LogParams,
  RestClient,
  WebsocketClient,
} from 'bitmart-api';

const restClient = new RestClient();

const customLogger: typeof DefaultLogger = {
  trace: (...params: LogParams): void => {
    console.log('silly', ...params);
  },
  info: (...params: LogParams): void => {
    console.info(params);
  },
  error: (...params: LogParams): void => {
    console.error(params);
  },
};

const client = new WebsocketClient(undefined, customLogger);

client.on('open', (data) => {
  console.log('connected ', data?.wsKey);
});

client.on('response', (data) => {
  console.info('response: ', data);
});

const tickers = await restClient.getSpotTickersV3();
const arrSpot = tickers.data.map((i) => `spot/depth20:${i[0]}`);

client.subscribe(arrSpot.slice(0, 90), 'spot');

Additional Information

@tiagosiebler tiagosiebler changed the title fix(v2.1.9): break subscription requests into batches of 20 fix(v2.1.9): split subscription requests into batches of 20 Nov 18, 2024
@tiagosiebler tiagosiebler merged commit 7bf6fc3 into master Nov 18, 2024
2 checks passed
@tiagosiebler tiagosiebler deleted the subrequestlimit branch November 18, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant