Skip to main content

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-sdk-ws

Quick Start

from ensync_websocket import EnSyncEngine

# Initialize engine (uses default URL)
engine = EnSyncEngine()  # Default: wss://node.gms.ensync.cloud

# Or specify self-hosted EnSync Messaging Engine URL
# engine = EnSyncEngine("wss://custom-server.com")

# Create authenticated client
client = await engine.create_client("your-app-key")

# Publish a message
await client.publish(
    "orders/status",
    ["appId"],
    {"order_id": "123", "status": "completed"}
)

# Subscribe to messages with decorator pattern
subscription = client.subscribe("orders/status")

@subscription.handler
async def handle_message(message):
    print(f"Received: {message['payload']}")

# Access subscription control methods
await subscription.pause("Maintenance")
await subscription.resume()

Features

  • WebSocket Protocol: Real-time bidirectional message communication
  • Automatic Reconnection: Handles connection failures gracefully
  • TLS Support: Secure WebSocket (WSS) connections
  • Hybrid Encryption: End-to-end encryption with Ed25519 and AES-GCM
  • Message Acknowledgment: Manual or automatic acknowledgement
  • Message Replay: Request historical messages by ID
  • Pause/Resume: Control message flow with subscription pause/resume

Message Design Guidelines

  • Ensure the message name already exists in EnSync (provisioned via the UI) before publishing; only registered names are accepted by the platform
  • Use hierarchical message names such as company/service/message-type
  • Ensure payloads comply with any schema registered for that message name (schemas are optional but enforced when present)

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-sdk: High-performance gRPC client (recommended for production)

License

MIT License - see LICENSE file for 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.3.tar.gz (12.7 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.3-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ensync_sdk_ws-0.4.3.tar.gz
  • Upload date:
  • Size: 12.7 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.3.tar.gz
Algorithm Hash digest
SHA256 e94ce95c583187278ee5b25ccffdcf3cbee8c3c18a58eb5ac51d63e5bcb472e2
MD5 8eab242273c9b1827f5918f7dfb08491
BLAKE2b-256 e54c718c7eecb4d29541f4b4e178668e820f948f053c9b16b79131ecfc6db5a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ensync_sdk_ws-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 11.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b853b43beb6e0585b06cfe8261d3fe56c9c32e4c08142d1c2a18267c851d89e0
MD5 4284ad05685154ca6c816322a9b19d48
BLAKE2b-256 071ea793d1ad2555300b8e61f69a0cb580cb8cda22d972ee654ddc6fcc1ffc82

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.3 This release

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

Supported by

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