# websocket-client/websocket-client

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/websocket-client-websocket-client).**

3,706 stars · 777 forks · Python · Apache-2.0

## Links

- GitHub: https://github.com/websocket-client/websocket-client
- Homepage: https://websocket-client.readthedocs.io/
- awesome-repositories: https://awesome-repositories.com/repository/websocket-client-websocket-client.md

## Topics

`python` `rfc-6455` `websocket` `websocket-client` `websockets` `websockets-client`

## Description

This is a Python WebSocket client library designed to establish full-duplex, persistent network connections for real-time exchange of text and binary data. It functions as an asynchronous network client and a TCP socket wrapper, managing the complete lifecycle of a connection from the initial handshake to graceful closure.

The implementation includes a secure WebSocket client that handles SSL/TLS encryption, certificate verification, and secure handshake protocols. It further distinguishes itself by supporting advanced connectivity options, including proxy routing via HTTP or SOCKS proxies and the integration of custom Unix domain sockets.

The library provides broad capabilities for connection management, including heartbeat monitoring through ping and pong frames to detect timeouts and thread-safe session handling to prevent data corruption. It also includes tools for connection traffic tracing, custom frame masking, and the ability to configure specific handshake headers and subprotocols.

## Tags

### Networking & Communication

- [Persistent Full-Duplex Connections](https://awesome-repositories.com/f/networking-communication/persistent-full-duplex-connections.md) — Establishes persistent, bidirectional communication links for simultaneous two-way data exchange between client and server. ([source](https://websocket-client.readthedocs.io/](https://websocket-client.readthedocs.io/))
- [WebSocket Clients](https://awesome-repositories.com/f/networking-communication/websocket-clients.md) — Provides a full-duplex Python library for establishing and managing bidirectional WebSocket connections over HTTP.
- [Asynchronous Network Clients](https://awesome-repositories.com/f/networking-communication/asynchronous-network-clients.md) — Functions as a non-blocking network client utilizing event loops for concurrent data transmission.
- [Websocket Connection Managers](https://awesome-repositories.com/f/networking-communication/connection-management/websocket-connection-managers.md) — Manages the full WebSocket lifecycle including connection establishment, heartbeat maintenance, and graceful closure.
- [Data Framing](https://awesome-repositories.com/f/networking-communication/data-framing.md) — Packages text and binary payloads into discrete binary frames for network transmission according to the WebSocket protocol.
- [Connection Lifecycle Managers](https://awesome-repositories.com/f/networking-communication/network-reliability-diagnostics/connection-session-management/connection-management/connection-lifecycle-managers.md) — Manages the full state transition sequence of opening, transmitting, and closing persistent network connections. ([source](https://websocket-client.readthedocs.io/))
- [WebSocket Message Exchanges](https://awesome-repositories.com/f/networking-communication/text-and-binary-message-exchanges/websocket-message-exchanges.md) — Provides bidirectional transmission of text and binary frames over persistent WebSocket connections. ([source](https://websocket-client.readthedocs.io/_sources/index.rst.txt))
- [WebSocket Connection Establishment](https://awesome-repositories.com/f/networking-communication/websocket-connection-establishment.md) — Handles the initial HTTP upgrade handshake to establish a real-time persistent WebSocket connection.
- [Thread-Safe Client Handling](https://awesome-repositories.com/f/networking-communication/concurrent-connection-threading/thread-safe-client-handling.md) — Ensures thread safety and prevents race conditions when multiple threads interact with the WebSocket client. ([source](https://websocket-client.readthedocs.io/en/latest/threading.html))
- [Connection Control Frame Handlers](https://awesome-repositories.com/f/networking-communication/connection-control-frame-handlers.md) — Manages protocol-level control frames and specifies opcodes to distinguish between text, binary, and control payloads. ([source](https://websocket-client.readthedocs.io/en/latest/examples.html))
- [Connection Maintenance Loops](https://awesome-repositories.com/f/networking-communication/connection-maintenance-loops.md) — Runs a continuous execution loop to monitor network health and handle automatic reconnections for persistent sessions. ([source](https://cdn.jsdelivr.net/gh/websocket-client/websocket-client@master/README.md))
- [Connection Closures](https://awesome-repositories.com/f/networking-communication/connection-management/websocket-connection-managers/websocket-connection-modifications/connection-closures.md) — Provides mechanisms to gracefully shut down the WebSocket transport stream using specific status codes. ([source](https://websocket-client.readthedocs.io/en/latest/examples.html))
- [Connection Managers](https://awesome-repositories.com/f/networking-communication/connection-managers.md) — Uses an asynchronous dispatcher to manage several active network socket sessions within a single process. ([source](https://websocket-client.readthedocs.io/en/latest/examples.html))
- [Unix Socket Connections](https://awesome-repositories.com/f/networking-communication/connection-managers/unix-socket-connections.md) — Supports establishing direct network connections using Unix domain sockets via filesystem paths. ([source](https://websocket-client.readthedocs.io/en/latest/examples.html))
- [Incoming Message Processors](https://awesome-repositories.com/f/networking-communication/incoming-message-processors.md) — Dispatches received server messages to specific application handlers using custom subprotocols. ([source](https://websocket-client.readthedocs.io/))
- [WebSocket Proxy Routings](https://awesome-repositories.com/f/networking-communication/network-infrastructure-routing/network-infrastructure-configuration/network-management/dns-connectivity-management/network-connectivity-configurations/proxy-connection-sharing/proxy-connection-configurations/websocket-proxy-routings.md) — Routes WebSocket traffic through HTTP or SOCKS proxies to bypass network restrictions. ([source](https://websocket-client.readthedocs.io/en/latest/examples.html))
- [Python Network Stacks](https://awesome-repositories.com/f/networking-communication/python-network-stacks.md) — Provides a network communication implementation built using Python sockets for handling WebSocket traffic.
- [Socket Abstractions](https://awesome-repositories.com/f/networking-communication/socket-interfaces/socket-abstractions.md) — Provides a socket abstraction layer that supports custom IP addresses and Unix domain sockets.
- [Socket Wrappers](https://awesome-repositories.com/f/networking-communication/socket-networking/socket-proxying-layers/socket-wrappers.md) — Wraps standard network sockets to support Unix domain sockets and routing via HTTP or SOCKS proxies.
- [Heartbeat Frames](https://awesome-repositories.com/f/networking-communication/tcp-connection-lifecycles/tcp-connection-acceptance/application-level-connection-acceptance/heartbeat-frames.md) — Employs periodic application-level ping and pong frames to detect timeouts and maintain active network links.

### Security & Cryptography

- [Secure Connection Handlers](https://awesome-repositories.com/f/security-cryptography/secure-connection-handlers.md) — Manages secure connection layers including TLS encryption, hostname verification, and certificate validation. ([source](https://websocket-client.readthedocs.io/))
- [WebSocket Security](https://awesome-repositories.com/f/security-cryptography/websocket-security.md) — Implements security controls for persistent WebSocket connections including SSL/TLS encryption and certificate verification.

### Software Engineering & Architecture

- [Thread-Safe Connection Sessions](https://awesome-repositories.com/f/software-engineering-architecture/c-thread-management-utilities/thread-safe-development/thread-safe-connection-sessions.md) — Uses locking mechanisms to prevent data corruption when multiple threads interact with a single network connection.
- [Callback-Based Event Dispatchers](https://awesome-repositories.com/f/software-engineering-architecture/callback-based-event-dispatchers.md) — Implements an event-driven dispatcher that routes incoming WebSocket protocol events to application-defined callback functions.
- [Connection Configurators](https://awesome-repositories.com/f/software-engineering-architecture/default-configuration-values/execution-parameter-configurations/application-parameter-configurators/configuration-parameter-injection/connection-configurators.md) — Allows defining protocol-level settings such as handshake headers, subprotocols, and timeout values. ([source](https://websocket-client.readthedocs.io/en/latest/examples.html))
