KuCoin `token is expired` error when reconnecting after running for 24 hours

Open
#4,740 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
api

Research direction

Start by inspecting the xchange-stream-kucoin WebSocket reconnect path and how it obtains KuCoin tokens through REST. Reproduce a reconnect after the 24-hour token lifetime, then verify that an expired-token error causes a fresh token request before reconnecting successfully.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Java
Stars
4.1k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
21

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from knowm/XChange

All issues in knowm/XChange

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.