Skip to content

fix(live): map http base_url to ws and omit ssl kwarg for ws:// URIs - #3462

Open
Roxen-AS wants to merge 1 commit into
googleapis:mainfrom
Roxen-AS:fix/live-websocket-http-scheme
Open

Roxen-AS wants to merge 1 commit into
googleapis:mainfrom
Roxen-AS:fix/live-websocket-http-scheme

Conversation

@Roxen-AS

@Roxen-AS Roxen-AS commented Dec 3, 2026

Copy link
Copy Markdown

Summary

Fixes #3451.

When connecting to the Live API over a plaintext http:// proxy (or an explicit ws:// URL), two issues prevented WebSocket connections:

  1. BaseApiClient._websocket_base_url() unconditionally replaced the URL scheme with 'wss' even when http_options.base_url used http:// or ws:// (and could apply to_mtls_url even for plaintext ws).
  2. AsyncLive.connect() unconditionally unpacked self._api_client._websocket_ssl_ctx into ws_connect(...), which passes ssl=... to websockets.connect and raises ValueError: ssl argument is incompatible with a ws:// URI.

Changes

  • Map 'http' -> 'ws' and 'https' -> 'wss' (preserving 'ws'/'wss') in BaseApiClient._websocket_base_url(), and only apply to_mtls_url when scheme == 'wss'.
  • Strip 'ssl' from ws_connect kwargs in AsyncLive.connect() when the target URI is not wss:// (matching _interactions_websocket.py).
  • Added unit tests in google/genai/tests/live/test_live.py.

Testing

  • pytest google/genai/tests/live/test_live.py -k "websocket or ssl_kwarg" -q: 6 passed
  • pytest google/genai/tests/live/test_live_music.py google/genai/tests/client/test_client_initialization.py -q: 166 passed
  • mypy google/genai/_api_client.py google/genai/live.py: Success: no issues found in 2 source files

Signed-off-by: Roxen-AS <akash.arjun12@gmail.com>

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

size:XL Code changes > 100 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Live (Vertex AI): WebSocket URL always uses wss, even when base_url is http

2 participants