Skip to content

Authentication check doesn't work properly for websocket stream connections which require authentication #63

Description

@lz-44

When subscribing to a stream that requires authentication (e.g. wallet stream) like this:

WebsocketStreamClient wsClient = this.wsFactory.newWebsocketClient(this::handleWalletEvent);
wsClient.getPrivateChannelStream(List.of("wallet"), "/v5/private");

we are getting the following error:
[OkHttp https://stream-testnet.bybit.com/...] ERROR c.b.a.c.w.i.WebsocketStreamClientImpl - Authentication failed.

After debugging a bit I found that the error happens with the messages of auth type, like this:

{
  "req_id": "1e979e9f-c8ea-44f5-a631-79fc82af7f41",
  "success": true,
  **"ret_msg": ""**,
  "op": "auth",
  "conn_id": "cqg7829qo29sr7bfifu0-cuck"
}

Despite the authentication in fact was successful, the check had failed:
isAuthenticated = msg.contains(""retCode":0"); (WebsocketStreamClientImpl:265)

and that's why we see the error message.

I have been using this API for a while and don't remember these errors. Probably the response from Bybit has been slightly changed. Maybe we should rely on "success" field?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions