sammchardy / python-kucoin

Kucoin REST and Websocket API python implementation
https://python-kucoin.readthedocs.io/en/latest/
MIT License
349 stars 147 forks source link

Unable to subscribe to more than 21 orderbooks #52

Closed stanith1 closed 5 years ago

stanith1 commented 5 years ago

Hi,

I'm currently trying out the latest websockets implementation, it seems that no matter how slowly I try to subscribe to the level2 orderbook streams I always get an exception thrown saying the connection has been closed when trying to subscribe to more than 21 orderbooks. Has anyone else been able to successfully subscribe to all orderbooks on the exchange using this wrapper?

I get the following: websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1000 (OK), no reason

stanith1 commented 5 years ago

To clarify, I actually get no exception initially (data just stops coming in after subscribing to the 22nd orderbook). Only when attempting to subscribe to the 23rd orderbook is that exception above thrown.

stanith1 commented 5 years ago

Problem solved, there was an unhandled error in my handle event function that wasn't being shown in the callstack. One of the topic subscriptions was invalid, if an error is returned the 'topic' and 'subject' fields don't exist in the message and it looks like as follows instead:

{'code': 404, 'data': 'topic /market/level2:BSV-BTC is not found', 'id': '1551623050668', 'type': 'error'}

That said, it appears that the max number of subscriptions is 100 anyway so that's something to bear in mind (might need multiple sockets or something?).