Skip to main content

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

ensync_sdk_ws-0.4.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ensync_sdk_ws-0.4.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file ensync_sdk_ws-0.4.1.tar.gz.

File metadata

  • Download URL: ensync_sdk_ws-0.4.1.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

Hashes for ensync_sdk_ws-0.4.1.tar.gz
Algorithm Hash digest
SHA256 0249d2456c78a4138c7f9a983dde600634019d28e028793239e77847deedec7a
MD5 92982089ec29970464b9330c82d36a5e
BLAKE2b-256 3fe238675398b31b489b9eeda2aa22897d4efb6ccde3c427bdc087466d2c10c7

See more details on using hashes here.

File details

Details for the file ensync_sdk_ws-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: ensync_sdk_ws-0.4.1-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

Hashes for ensync_sdk_ws-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f93c2150d85e216e641da82148b537692b5d614135bfd51fa0e4c663cdab883
MD5 9c10dff121a94511da17b846f74f5559
BLAKE2b-256 90113f0f1903d22e28ae4e1ba7154d346b32bd0495d757ef9d27d2e3ccd8c104

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page