altangent / ccxws

WebSocket client for 38 cryptocurrency exchanges
MIT License
617 stars 186 forks source link

Binance stops streaming #214

Open Albot15 opened 3 years ago

Albot15 commented 3 years ago

Exchange Binance, Binance Futures

Subscription type Ticker

Describe the bug I noticed recently Binancea and Binance Futures stops streaming data randomly. I tested with ticker streaming (!ticker@arr) and if i restart it, then it start working again. However, it stops again after few hours.

Note: There is no error in console

I also tested aggTrade endpoint and it works great and not stoping at all.

Anyone experiencing similar issue?

bmancini55 commented 3 years ago

Thanks for submitting an issue!

Any chance you see a disconnected event when this happens? There is a flag that checks if tickers are subscribed. It only get cleared during the closing event but not disconnected. I'm guessing this is an issue with the socket gets disconnected and when it reconnects it fails to resent the !ticker@arr message because the flag hasn't been cleared.

Albot15 commented 3 years ago

Thanks for the reply.

There is nothing in console log about disconnected event. Do i need to console any specific variable to monitor disconnects? If, yes please let me know which one.

bmancini55 commented 3 years ago

You need to attach an event listener to the disconnected event:

client.on("disconnected", () => console.log("disconnected"));
client.on("reconnecting", () => console.log("reconnecting"));
client.on("connecting", () => console.log("connecting"));
client.on("connected", () => console.log("connected"));
Albot15 commented 3 years ago

Thanks, I will attach these events and let you know

Albot15 commented 3 years ago

Hi,

This time it took days to stop streaming and today i got printed console. disconnected reconnecting connecting connected reconnecting connecting connected reconnecting connecting connected

This keeps going and won't stop until i restart node.

bmancini55 commented 3 years ago

Thanks for taking the time to capture this! Will hopefully have a fix in soon.

bifot commented 2 years ago

any updates here?

nileio commented 2 years ago

hi there @bifot are those happening in sequence immediately one after the other ? I noticed there is no "disconnected" event apart from the first ? did you manage to find a solution or are you experiencing the same issue still ?

alanwu4321 commented 1 year ago

Experience this issue as well

bifot commented 1 year ago

i'm not experiencing this issue anymore, just installed latest version of ccxws and everything is fine

one year ago i was experiencing this issue because sometimes i did unsubscribe before fetching all markets (and subscribe after as well) and request on fetch markets failed so subscribe didn't triggered