Closed tristan-murfitt-elw closed 2 years ago
I feel like canceling a task is a surefire way to get disconnection errors like this. Why not shut that task down gracefully? If you look at the stop method:
https://github.com/bmoscon/cryptofeed/blob/master/cryptofeed/feedhandler.py#L172
you can see what it does to a feed - it calls stop, and then creates a task to call feed.shutdown. Not all of what goes on it shutdown is necessary, but it does then close the connections. I think if you want to not get errors like this you'll need to do something like this and gracefully close it out, or implement an unsubscribe method for exchanges and call that and then close the connection
@bmoscon thanks for pointing these new methods out - this is a huge value add since the last release!
As for the ConnectionClosedError 1006 IncompleteReadError
problem: this does happen often (and will continue to) just due to the nature of crypto infrastructure. Force cancellation of asnycio tasks is a great way to replicate the problem to see how we can make the library more resilient. I spent some time to try and understand why this was affecting Gateio feeds specifically, and not other exchanges, but to no avail. Maybe we can keep this pinned and refer back here if anybody else notices this becoming prevalent?
going to close this, but if anyone has any issues that look similar, please comment here or open a new ticket.
Describe the bug Same bug as https://github.com/bmoscon/cryptofeed/issues/308 but I've managed to replicate this on a consistent basis.
Background: I have a requirement to disconnect particular feeds without restarting the feedhandler. To solve this I maintain a list of asyncio task objects in the
FeedHandler
whenever a feed is added. Then I can cancel any of these tasks from my main app. My fork is behind on your new connection changes, but it's just a simple modification here .To Reproduce
task.cancel()
on some running feed tasksIncompleteReadError
orConnectionClosedError
, it gracefully cancels the task.I'm seeing this error from "natural" use too. Above seems to be a good way to replicate.
Expected behavior Gateio should gracefully handle abrupt WS closures as the other exchanges do. Is there any reason why it would behave differently?
Cryptofeed Version