Skip to content

Connect the websocket through the v2 endpoint behind an internal flag, still off by default - #6865

Draft
gpunto wants to merge 1 commit into
developfrom
migrate/socket-v2-2-connect
Draft

gpunto wants to merge 1 commit into
developfrom
migrate/socket-v2-2-connect

Conversation

@gpunto

@gpunto gpunto commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Goal

Add the v2 websocket connection, the second step of moving the socket to v2. It sits behind an internal flag that is off by default, so the socket still connects on v1 until a later PR flips it.

Part of AND-1637

Implementation

  • ChatClient.Builder.useV2WebSocket(enabled) (@InternalStreamChatApi) makes the socket connect to /api/v2/connect and parse its frames with V2EventParser.
  • The v2 socket authenticates with a frame sent once open (token, user details with custom data under custom, the chat product) instead of the URL and Authorization header. Reconnections send the user id only, as on v1. Anonymous users connect with the anonymous auth type and a placeholder token.
  • The keepalive is a minimal health.check frame for the connection on v2, and the echoed connection event on v1, as before.
  • A v2 frame that fails to parse is handled as on v1: dropped and logged once connected, a connection error before.

Testing

  • V2SocketTest covers the v2 URL without an Authorization header, the auth frame on first connection, reconnection and for anonymous users, the keepalive frame, frame parsing, and the socket staying on v1 without the flag.
  • CurrentUserFetcherTests covers fetching the own user when the v2 socket connects.

@gpunto gpunto added the pr:internal Internal changes / housekeeping label Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.25 MB 6.25 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.57 MB 11.57 MB 0.00 MB 🟢
stream-chat-android-compose 13.23 MB 13.24 MB 0.00 MB 🟢
stream-chat-android-ai-compose 2.07 MB 2.07 MB 0.00 MB 🟢
stream-chat-android-ai-ondevice 1.67 MB 1.67 MB 0.00 MB 🟢

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

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

Labels

pr:internal Internal changes / housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant