Syntic

Skills may execute instructions and code that could affect your environment. Marketplace scans reduce risk but do not guarantee safety. Always review files, run your own security checks, and use at your own risk.

EngineeringFree Safe

Websocket Engineer

Security Scan Summary

Status: Safe

Source: Syntic Skills registry

Automated security scan completed with no high-risk patterns detected. Manual review is still required.

About This Skill

Use when building real-time communication systems, scaling WebSocket servers, or implementing reconnection and backpressure strategies.

Downloadable SKILL.md

Download SKILL.md and place it in your Syntic skills folder. For Syntic Code, install in your local skills directory, review contents, and run in a controlled environment first. Acknowledge the risk notice above to enable the download.

SKILL.md
---
name: Websocket Engineer
description: Use when building real-time communication systems, scaling WebSocket servers, or implementing reconnection and backpressure strategies.
category: Engineering
version: 1.0.0
tools: []
---

# WebSocket Engineer

Build reliable WebSocket infrastructure for live applications. Design for connection resilience, horizontal scaling, and efficient message delivery across thousands of concurrent connections.

## Core Principles

- WebSocket connections are stateful and long-lived. Design every component to handle unexpected disconnections gracefully.
- Prefer Socket.io for applications needing automatic reconnection, room management, and transport fallback. Use raw `ws` for maximum performance with minimal overhead.
- Every message must be deliverable exactly once from the client's perspective. Implement idempotency keys and acknowledgment patterns.
- Real-time does not mean unthrottled. Apply rate limiting and backpressure to prevent a single client from overwhelming the server.

## Connection Lifecycle

- Authenticate during the handshake, not after. Use JWT tokens in the `auth` option (Socket.io) or the first message (raw WebSocket).
- Implement heartbeat pings every 25 seconds with a 5-second pong timeout. Kill connections that fail two consecutive heartbeats.
- Track connection state on the client: `connecting`, `connected`, `reconnecting`, `disconnected`. Update UI accordingly.
- Use exponential backoff with jitter for reconnection: `min(30s, baseDelay * 2^attempt + random(0, 1000ms))`.

## Socket.io Architecture

- Use namespaces to separate concerns: `/chat`, `/notifications`, `/live-updates`. Each namespace has independent middleware.
- Use rooms for grouping: `socket.join(\`user:\${userId}\`)` for user-targeted messages, `socket.join(\`room:\${roomId}\`)` for broadcasts.
- Emit with acknowledgments for critical operations: `socket.emit("message", data, (ack) => { ... })`.
- Define event names as constants in a shared module.

## Horizontal Scaling

- Use the `@socket.io/redis-adapter` to synchronize events across multiple server instances behind a load balancer.
- Configure sticky sessions at the load balancer level (based on session ID cookie) so transport upgrades work correctly.
- Use Redis Pub/Sub or NATS for broadcasting messages across server instances.
- Store connection-to-server mapping in Redis for targeted message delivery to specific users across the cluster.

## Backpressure and Rate Limiting

- Track send buffer size per connection. Disconnect clients whose buffer exceeds 1MB (data not being consumed).
- Rate limit incoming messages per connection: 100 messages per second for chat, 10 per second for API-style operations.
- Implement per-room fan-out limits. Broadcasting to a room with 100K members must use batched sends with configurable concurrency.

## Security

- Validate every incoming message against a schema. Malformed messages get dropped with an error response, not a crash.
- Sanitize user-generated content before broadcasting. XSS through WebSocket messages is a real attack vector.
- Implement per-user connection limits (max 5 concurrent connections per user) to prevent resource exhaustion.
- Use WSS (WebSocket Secure) exclusively. Never allow unencrypted WebSocket connections in production.

Bundle Download

Includes SKILL.md and bundled support files where provided. Risk acknowledgement is required.

Install Targets

Syntic App

  1. 1. Create a dedicated folder for this skill in your local skills library.
  2. 2. Place SKILL.md into that folder.
  3. 3. Restart Syntic and invoke this skill on matching tasks.

Syntic Code (CLI)

  1. 1. Save SKILL.md in your local Syntic Code skills directory.
  2. 2. Keep related files in the same skill folder.
  3. 3. Run in a safe environment and validate outputs.

Source

https://github.com/rohitg00/awesome-claude-code-toolkit/blob/main/agents/core-development/websocket-engineer.md

Open Source Link
Engineering

Related Skills