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 4 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

How about use

handleErrorMessage (client, message) {
    if (id in client.subscriptions) {
        delete client.subscriptions[id]; // can we simply update this line to delete client.subscriptions[messageHash];
    }
}

sc0Vu avatar Apr 22 '22 04:04 sc0Vu

@sc0Vu i think it could be something like:

                    client.reject (e, messageHash);
                    client.reject (e, id);
                    if (id in client.subscriptions) {
                        delete client.subscriptions[id];
                    }
                    if (messageHash in client.subscriptions) {
                        delete client.subscriptions[messageHash];
                    }

It would be great if you could test it with various incorrect params to get that error intentionally and to make sure that it is properly handled. Thx!

UPD

kroitor avatar Apr 22 '22 04:04 kroitor