XChange
XChange copied to clipboard
KuCoin `token is expired` error when reconnecting after running for 24 hours
I'm testing the KuCoin WebSockets implementation of xchange-stream-kucoin
version 5.1.1-SNAPSHOT
. Retrieving market data works fine. The WebSocket connection is created using a token that is valid for 24 hours. When there's a connection reset, XChange automatically reconnects the WebSocket using the same token. So far so good.
Only when the process is running for more than 24 hours XChange can't reconnect anymore because it uses a token that is expired. The reconnect will result in: handleError cannot parse channel from message: {"type":"error","code":401,"data":"token is expired"}
It would be nice if the XChange library would reconnect using a new token in this case. So I think it should first GET a new token via REST before connecting to WebSocket again. In my code I now implemented a work-around which disconnects and sets up a new connection (automatically with new token) every 24 hours.