Skip to content

Use the wss scheme for WebSocket connections over TLS - #215

Merged
vrslev merged 1 commit into
community-of-python:mainfrom
GLeurquin:fix/websocket-tls
Nov 10, 2026
Merged

vrslev merged 1 commit into
community-of-python:mainfrom
GLeurquin:fix/websocket-tls

Conversation

@GLeurquin

Copy link
Copy Markdown
Contributor

Fixes #212.

Summary

  • WebSocketConnection.connect built ws://{host}:{port}/{path} whatever ssl was, and websockets refuses an ssl argument on a ws:// URI, so a connection over TLS could not be made.
  • The scheme now follows ssl: wss when it is set, the scheme RFC 6455, section 3 defines for WebSocket over TLS, and ws otherwise.

Validation

  • just lint
  • just check-types
  • just test-fast: 447 passed. test_connection_uri_scheme_follows_ssl checks the URI handed to websockets.connect for ssl=None and ssl=True, and fails without the change.
  • just test (integration) not run.

Note

test_connection_ws.py is skipped unless the root ws dependency group is installed (uv sync --all-groups). just install, which every CI job runs, installs extras only, so CI currently skips the WebSocket tests, this one included. Happy to open a separate PR adding the group to just install.

WebSocketConnection built a ws:// URI whatever ssl was, and websockets refuses
an ssl argument on a ws:// URI ("ssl argument is incompatible with a ws://
URI"), so a connection with ssl set could never be made. RFC 6455 names
WebSocket over TLS wss://; the scheme now follows ssl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vrslev
vrslev merged commit 3d6a2c5 into community-of-python:main Nov 10, 2026
7 checks passed
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.

WebSocketConnection cannot connect over TLS

2 participants