WebSocket client for EnSync Engine - real-time messaging over WebSocket
Project description
EnSync WebSocket Client
WebSocket client for EnSync Engine. An alternative to the gRPC client for environments where WebSocket is preferred or required.
Installation
pip install ensync-websocket
Quick Start
from ensync_websocket import EnSyncEngine
# Initialize engine
engine = EnSyncEngine("wss://node.ensync.cloud")
# Create authenticated client
client = await engine.create_client("your-app-key")
# Publish an event
await client.publish(
"orders/status/updated",
["recipient-app-id"],
{"order_id": "123", "status": "completed"}
)
# Subscribe to events
subscription = await client.subscribe("orders/status/updated")
async def handle_event(event):
print(f"Received: {event['payload']}")
subscription.on(handle_event)
Features
- WebSocket Protocol: Real-time bidirectional communication
- Automatic Reconnection: Handles connection failures gracefully
- TLS Support: Secure WebSocket (WSS) connections
- Hybrid Encryption: End-to-end encryption with Ed25519 and AES-GCM
- Event Acknowledgment: Manual or automatic event acknowledgment
- Event Replay: Request historical events by ID
- Pause/Resume: Control event flow with subscription pause/continue
Connection Options
# Secure WebSocket (production)
engine = EnSyncEngine("wss://node.ensync.cloud")
# Insecure WebSocket (development)
engine = EnSyncEngine("ws://localhost:8080")
# With options
engine = EnSyncEngine("wss://node.ensync.cloud", {
"enableLogging": True,
"reconnect_interval": 5000,
"max_reconnect_attempts": 10
})
When to Use WebSocket vs gRPC
Use WebSocket when:
- You need browser compatibility
- Your infrastructure has better WebSocket support
- You're working in restricted environments where gRPC is blocked
- You prefer text-based protocols for debugging
Use gRPC when:
- You need maximum performance
- You're building server-to-server communication
- You want built-in load balancing and service mesh integration
- Binary protocol efficiency is important
For most production use cases, we recommend the ensync-grpc package for better performance.
Documentation
For complete documentation, examples, and API reference, visit:
Related Packages
- ensync-core: Core utilities (automatically installed as dependency)
- ensync-grpc: High-performance gRPC client (recommended for production)
License
MIT License - see LICENSE file for details
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ensync_sdk_ws-0.4.0.tar.gz.
File metadata
- Download URL: ensync_sdk_ws-0.4.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b580634436eb7bed0c0fe00750f19f84e883e8700fc0731518650666dbfa3bb
|
|
| MD5 |
905c325d96ffd7eca494eee3e4504e7b
|
|
| BLAKE2b-256 |
a67a0e8bd8ec4b71642fbd931406da0c66429dc2ac90a190fa2851e6f24072c3
|
File details
Details for the file ensync_sdk_ws-0.4.0-py3-none-any.whl.
File metadata
- Download URL: ensync_sdk_ws-0.4.0-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
209b7fce3b8e54ed52fa0fcbde4b177b921a2daca1f711bb2c2db5a19ffa1a17
|
|
| MD5 |
e626bd1b54bfb3d1211d52f7824b43ee
|
|
| BLAKE2b-256 |
632ffa70392f30ff4014738b72a8c671330ecb8c83c0625639f528545a045e8b
|