A high-performance, multi-tenant WebSocket orchestration layer engineered for real-time collaboration, instant data synchronization, and ultra-low latency event streaming. This module serves as the primary gateway for end-user web applications interacting with the CoCreate clustered network.
For complete API references, protocol event schemas, configuration guides, and examples, visit the CoCreate Socket Server Documentation.
- Documentation
- The Real-Time Multiplexing Core
- Why CoCreate Socket Server?
- Multi-Tenant Rooms & Subscriptions
- The Connection Degradation Vector
- Graceful Reconnection & State Recovery
- Configuration
- Installation
- How to Contribute
- License
@cocreate/socket-server manages hundreds of thousands of concurrent persistent client connections with a zero-allocation, stream-oriented architecture.
To minimize serialization overhead and avoid high CPU usage, all real-time payloads can be encoded natively as binary streams using protocol buffers or compact JSON-in-MsgPack formats. This reduces network payload size by up to 60% compared to raw stringified JSON payloads.
Sockets are automatically classified upon connection based on authenticated organization context. Client connections can only subscribe to channels matching their tenant scopes, keeping data partitions strict and secure at the gateway edge.
[Client App] ──► [WebSocket Connection] ──► [Socket Server Edge] ──► [Tenant Context Mapping]
│
▼
[Enforced Privacy]
Standard real-time libraries (such as Socket.IO) introduce protocol wrapping overhead and maintain relatively heavy memory footprints per client, limiting total connection density on typical hardware.
@cocreate/socket-server is built on top of high-performance, low-level engine bindings, ensuring near-native socket operations. It tracks user presence, real-time collaboration, and administrative events with minimal overhead, allowing a single server instance to support tens of thousands of concurrent active connections.
The socket server divides message distributions into isolated communication layers.
| Channel Scope | Delivery Mechanism | Common Use Case |
|---|---|---|
| Organization Room | Broadcast across tenant nodes | System announcements and configuration synchronization. |
| Document Room | Focused cluster routing | Real-time collaboration, cursor synchronization, and document updates. |
| User Direct Channel | Unicast targeted messaging | Personal notifications and account-specific events. |
| Mesh Control Tunnel | Internal inter-server communication | Administrative coordination and node draining. |
To help @cocreate/server-telemetry evaluate worker saturation, the socket server continuously tracks local connection density (
As connection density approaches configured limits, the socket server notifies the surrounding infrastructure so new client connections can be routed toward healthier nodes.
Temporary network interruptions should not interrupt collaboration.
When a client disconnects unexpectedly, its session is placed into a short-lived recovery state. Outbound events are temporarily buffered in memory. If the client reconnects with its session identifier before the recovery window expires, pending events are replayed and synchronization continues without requiring the application to rebuild state.
Create a socket.config.json file in your server root directory.
{
"port": 8080,
"maxConnections": 50000,
"pingIntervalMs": 25000,
"pingTimeoutMs": 5000,
"maxPayloadBytes": 1048576,
"compression": {
"enabled": true,
"thresholdBytes": 1024
},
"security": {
"requireAuth": true,
"authTimeoutMs": 5000
}
}npm install @cocreate/socket-serveryarn add @cocreate/socket-serverWe encourage contributions to all CoCreate libraries. Please see our CONTRIBUTING.md guide for development workflows and contribution guidelines.
If you discover a bug or would like to request a feature, please open an issue on our GitHub Issues tracker.
For complete documentation, examples, and integration guides, visit:
https://cocreatejs.com/docs/socket-server
This software is dual-licensed under the GNU Affero General Public License version 3 (AGPLv3) and a commercial license.
- Open Source Use: For open-source projects and non-commercial use, this software is available under the AGPLv3. See the LICENSE file for the complete license text.
- Commercial Use: Commercial users must obtain a commercial license. Commercial licenses are available when signing up for an API key through the CoCreate platform.