websocket-client

A low-level, dependency-free WebSocket client for Python supporting both synchronous and event-driven connections.

Library
PyPI
v1.9.1
3,708stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
68/100Good
Development Activity56
Maintenance24
Community92
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture78
Code Quality84
Innovation65
Learning Curve90

websocket-client is a pure-Python WebSocket client library implementing the RFC 6455 (hybi-13) protocol with zero required dependencies. It exposes both a low-level WebSocket class for direct socket-level control and a higher-level WebSocketApp that mirrors the JavaScript WebSocket API with callback-based event handling (on_open, on_message, on_error, on_close).

Widely used as a standard choice for WebSocket connectivity in Python — from IoT device clients to market-data feeds to internal service tooling — the library has been maintained continuously since 2010, with the current maintainer team shipping regular releases, SSL/TLS and proxy support, automatic reconnection, and optional performance and testing extras via pip extras.

What You Get

  • A low-level WebSocket class exposing connect, send, recv, and close for direct protocol control
  • A WebSocketApp class mirroring the browser WebSocket API with on_open/on_message/on_error/on_close callbacks
  • Built-in SSL/TLS support plus HTTP/SOCKS proxy connection handling via _http.py
  • Automatic reconnection support via run_forever(dispatcher=..., reconnect=N) when paired with a dispatcher like rel
  • Optional wsaccel and python-socks extras for UTF-8 validation speedups and proxy support

Common Use Cases

  • Real-time market data feeds - trading and fintech developers use WebSocketApp.run_forever with automatic reconnect to maintain always-on connections to exchange data streams
  • IoT and device telemetry - device integrators embed the low-level WebSocket class to send/receive framed messages over constrained network links without pulling in async framework dependencies
  • Internal service-to-service push channels - backend engineers use the library for lightweight, synchronous WebSocket clients in scripts and services that don’t require an async event loop
  • Debugging and manual protocol testing - the bundled wsdump CLI utility (_wsdump.py) lets developers connect to and inspect a WebSocket endpoint interactively from the terminal

Under The Hood

Architecture The library separates protocol framing (_abnf.py, implementing RFC 6455 frame parsing), low-level socket handling (_core.py, the WebSocket class managing connect/send/recv over raw sockets), HTTP handshake and proxy tunneling (_http.py, _handshake.py), and a higher-level event-driven wrapper (_app.py, the WebSocketApp class) that composes the core WebSocket internally and drives it through a run_forever loop with pluggable dispatchers (_dispatcher.py) for reconnect and async-runtime integration. This is a modular, layered design — protocol layer, transport layer, handshake layer, then a high-level app layer — with __init__.py re-exporting the public surface via wildcard imports. Because both WebSocket and WebSocketApp ultimately depend on the same frame_buffer/continuous_frame primitives in _abnf.py, changes to core framing logic ripple through both API levels.

Tech Stack Pure Python 3.10+, with zero required runtime dependencies — install_requires is empty, relying entirely on the standard library’s socket, ssl, threading, and struct modules. Optional extras cover python-socks and wsaccel for proxy support and a C-accelerated UTF-8 validation/masking speedup, websockets for running the test suite’s local echo server, and Sphinx/sphinx_rtd_theme/myst-parser for documentation builds. Packaging uses setuptools>=77 via a pyproject.toml build-backend paired with a setup.py carrying the actual package metadata. Static typing is enforced separately through mypy.ini, targeting the websocket/ package while excluding tests and the _wsdump.py CLI tool. CI runs dedicated GitHub Actions workflows for linting, building, doctests, and code coverage via Codecov.

Code Quality An extensive test suite lives under websocket/tests/, spanning ABNF framing, app-level behavior, cookiejar handling, dispatcher logic, handshake edge cases, HTTP, large payloads, logging helpers, reconnect-on-bad-fd scenarios, socket bugs, SSL compatibility and edge cases, URL parsing, and general utilities — run with pytest. Core modules carry typed function signatures throughout (Optional/Union/Callable annotations in _core.py and _app.py) and are checked with mypy in CI. A custom exception hierarchy in _exceptions.py (WebSocketException, WebSocketProtocolException, WebSocketConnectionClosedException, WebSocketTimeoutException) gives callers granular error handling instead of bare exceptions, and code formatting follows the black style declared in the README.

API Design The library’s central developer-experience choice is offering two coexisting API levels under one import: a low-level WebSocket class for raw send/recv/close control, and a WebSocketApp deliberately modeled on the browser’s JavaScript WebSocket object so web developers can transfer intuition directly. A zero-required-dependency footprint keeps integration friction minimal, and optional extras are cleanly namespaced (pip install websocket-client[optional], [test], [docs]). It doesn’t extend the protocol itself — WebSocket Compression (RFC 7692) is explicitly unsupported — but the dual-API ergonomics and dependency-free design are its clearest differentiator against async-first alternatives like websockets or aiohttp.

Used by 9 apps in this directory

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,969

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python100%
Updated today
Go
82%
AGPL 3.0

Beta9

Developer Tools · AI Development · Data Engineering

1,762

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
84
Repo Health
78
Technical
67
Dependency
Built with
Go82%
Python17%
Updated 3 days ago
C++
69%
Apache 2.0

ClickHouse

Databases · Analytics · Data Engineering

49,535

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
C++69%
Python13%
Updated today
Python
100%
GPL 3.0

ComfyUI

AI Design Tools · AI Development

130,686

The most powerful node-based AI workflow engine for creating images, video, 3D models, and audio with full control over every generation step.

View details
92
Repo Health
81
Technical
75
Dependency
Built with
Python100%
Updated today
JavaScript
54%
MIT

GPU Hot

Monitoring · Devops

1,625

Real-time NVIDIA GPU monitoring dashboard — self-hosted, scale from 1 to 100+ GPUs with sub-second metrics and no cloud dependency.

View details
63
Repo Health
73
Technical
79
Dependency
Built with
JavaScript54%
Python34%
Updated 5 days ago
TypeScript
55%
Other

Jaaz

AI Design Tools · AI Agents

6,601

Open-source AI creative agent that turns visual sketches and canvas gestures into images and videos — no text prompts required.

View details
45
Repo Health
59
Technical
71
Dependency
Built with
TypeScript55%
Python34%
JavaScript10%
Updated 6 months ago
Python
64%
Other

Keep

Devops · Automation · Monitoring

12,259

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
91
Repo Health
79
Technical
66
Dependency
Built with
Python64%
TypeScript36%
Updated 6 days ago
Python
52%
Other

Odoo

ERP · CRM · Productivity

54,040

The open source ERP platform that integrates CRM, accounting, inventory, manufacturing, and 60+ business apps into one seamlessly connected suite.

View details
87
Repo Health
82
Technical
64
Dependency
Built with
Python52%
JavaScript43%
Updated today
Python
74%
AGPL 3.0

OpenViking

Databases · AI Development

34,389

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
84
Repo Health
75
Technical
65
Dependency
Built with
Python74%
Rust14%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search