Websocket Client Library
Maintained. Last release 2 months ago, commits in 4 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install lomondDataplicity Lomond
Tranquil WebSockets for Python.
Lomond is a Websocket client which turns a websocket connection in to an orderly stream of events. No threads or callbacks necessary.
How to Use
To connect to a "ws:" or "wss:" WebSocket URL, construct a lomond.WebSocket object then iterate over it. This will yield an event object for each step in the connection process and for any data sent by the server.
You will receive a Binary or Text event when the server sends you a message.
You may send a message with the send_binary or send_text methods.
TLS and Debugging
wss:// connections now verify TLS certificates by default. You can tune this
without changing global SSL behavior:
ws = WebSocket(
"wss://example.com/socket",
ssl_verify=True, # default
ssl_cafile="/etc/ssl/my-ca.pem", # optional custom CA bundle
)
For deep diagnostics, pass a trace callback and Lomond will emit structured records for connect, handshake, send/recv, and close stages: