Skip to content

fix: Detect demo-format WS auth ack (success:true) as success (#63)#89

Open
darekurlik wants to merge 1 commit intoJohnnyWic:mainfrom
darekurlik:fix/ws-auth-demo-success-field
Open

fix: Detect demo-format WS auth ack (success:true) as success (#63)#89
darekurlik wants to merge 1 commit intoJohnnyWic:mainfrom
darekurlik:fix/ws-auth-demo-success-field

Conversation

@darekurlik
Copy link
Copy Markdown

Problem

WebsocketStreamClientImpl.onMessage only treats "retCode":0 as a successful auth ack:

isAuthenticated = msg.contains("\"retCode\":0");

Bybit's demo trading private WebSocket (wss://stream-demo.bybit.com/v5/private) instead responds with:

{"req_id":"...","success":true,"ret_msg":"","op":"auth","conn_id":"..."}

No retCode field → lib reports "Authentication failed." and never flushes queued private subscriptions (order / position / execution / wallet), leaving the WS open but useless.

This is the same issue reported in #63.

Fix

Accept either signal as auth success:

isAuthenticated = msg.contains("\"retCode\":0")
        || (msg.contains("\"success\":true") && msg.contains("\"op\":\"auth\""));

Mainnet acks (which include retCode:0) keep working unchanged.

Verified

End-to-end against real Bybit demo with valid demo credentials:

Sent Auth: {"op":"auth","args":["...",1777463210561,"..."]}
WS msg:    {"success":true,"op":"auth","conn_id":"..."}
→ Authentication successful.
Sent Subscribe: {"op":"subscribe","args":["order","position","execution","wallet"]}
WS msg:    {"success":true,"op":"subscribe",...}

Closes #63.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant