kucoin-node-sdk icon indicating copy to clipboard operation
kucoin-node-sdk copied to clipboard

Websocket ticker_demo.js not working

Open juanmanavarro opened this issue 1 year ago • 0 comments

Any idea?

I'm not receiving the data in the susbcriber callback and datafeed.trustConnected is always false

API.init(config);

const datafeed = new API.websocket.Datafeed();

// close callback
datafeed.onClose(() => {
  console.log('ws closed, status ', datafeed.trustConnected);
});

// connect
await datafeed.connectSocket();

// subscribe
setTimeout(() => {
  console.log(datafeed.trustConnected);
  const topic = `/market/level2:BTC-EUR`;
  const callbackId = datafeed.subscribe(topic, (message) => {
    console.log(message);
    if (message.topic === topic) {
      console.log(message.data);
    }
  });
  console.log( `subscribe id: ${callbackId}` );
}, 5000);

juanmanavarro avatar Apr 19 '23 15:04 juanmanavarro