ccxt icon indicating copy to clipboard operation
ccxt copied to clipboard

ccxt.pro: Huobi: watch doesn't retry to subscribe after error

Open 4ext opened this issue 3 years ago • 3 comments

  • OS: Linux 5.10
  • Programming Language version: NodeJS v14.17
  • CCXT.PRO version: 0.9.5

Hello,

When I was trying out ccxt.pro with huobi I noticed that after a subscription (watchOHLCV) failed the first time, it seemed to be impossible to retry, unless I'm misunderstanding something.

After watchOHLCV threw the error (in this case it happened immediately, because the market was down temporarily), further calls to watchOHLCV didn't seem to retry but block indefinitely(?).

handleErrorMessage in huobi.js seems to fail to remove the subscription record on error and so calling watch again doesn't retry.

handleErrorMessage(client, message) {
.
.
if (id in client.subscriptions) {
     delete client.subscriptions[id];
}
.
.

Changing this to:

Object.keys(client.subscriptions).forEach((key) => {
  if (client.subscriptions[key].id === id) {
      delete client.subscriptions[key];
  }
});

seems to be working.

Is this ok or am I misunderstanding about how it's supposed to work in such case?

Thank you very much :)

4ext avatar Oct 21 '21 11:10 4ext