websocket-client is a WebSocket client library for Python that provides low-level access to WebSocket APIs and implements the hybi-13 version of the WebSocket protocol.
The library solves the problem of establishing and maintaining WebSocket connections in Python applications. It handles the protocol handshake, message framing, and connection management. The tool exposes both high-level convenience methods and low-level APIs, allowing developers to choose their level of abstraction depending on their needs. For long-lived connections, the WebSocketApp class offers a run_forever loop that can automatically reconnect when network connectivity is lost, either through an async dispatcher or by specifying a reconnect delay.
The library is suitable for Python applications that need reliable WebSocket communication. It works with Python 3.10 and later. Developers concerned with performance can disable UTF8 validation using the skip_utf8_validation parameter, or install the optional wsaccel package to roughly double UTF8 validation speed and provide a minor boost to payload masking. The project does not currently support the permessage-deflate compression extension from RFC 7692, which is a known limitation. Optional dependencies are available for proxy support, testing, and documentation building. The project's documentation includes a FAQ section and threading guidelines for developers integrating the library into concurrent applications.
The project maintains active engagement with its issue tracker and accepts community contributions through established guidelines. Development focuses on stability and compatibility across supported Python versions, with testing infrastructure in place. The maintainers have evaluated performance enhancement options empirically, such as testing Numpy as an alternative to wsaccel, demonstrating a pragmatic approach to optimization decisions.