| license | Apache-2.0 |
| name | websocket-realtime-expert |
| description | WebSockets, SSE, and real-time communication with Socket.io and native APIs. Activate on: WebSocket, real-time, SSE, Socket.io, live updates, push notifications, bidirectional, presence. NOT for: message queue infrastructure (use event-driven-architecture-expert), API gateway routing (use api-gateway-reverse-proxy-expert). |
| allowed-tools | Read,Write,Edit,Bash(npm:*,npx:*) |
| category | Backend & Infrastructure |
| tags | ["websocket","realtime","sse","socket-io","push"] |
| pairs-with | [{"skill":"event-driven-architecture-expert","reason":"Backend events feed real-time channels"},{"skill":"cache-strategy-invalidation-expert","reason":"Cache invalidation triggers real-time updates"},{"skill":"api-gateway-reverse-proxy-expert","reason":"WebSocket upgrade handling at the gateway"}] |
WebSocket & Real-Time Expert
Build reliable real-time communication systems using WebSockets, Server-Sent Events, and managed real-time services.
Activation Triggers
Activate on: "WebSocket", "real-time", "SSE", "Socket.io", "live updates", "push notifications", "bidirectional", "presence", "live cursors", "collaborative editing"
NOT for: Message queue setup â event-driven-architecture-expert | Gateway WebSocket routing â api-gateway-reverse-proxy-expert | Streaming data pipelines â streaming-pipeline-architect
Quick Start
- Choose protocol â WebSocket for bidirectional, SSE for server-push, WebTransport for low-latency
- Plan reconnection â exponential backoff with jitter, resume from last event ID
- Design message format â typed JSON with
type discriminator and monotonic sequence IDs
- Scale horizontally â use Redis Pub/Sub or NATS as a broadcast backplane
- Handle presence â heartbeat-based with configurable timeout (30s default)
Core Capabilities
| Domain | Technologies |
|---|
| WebSocket | ws (Node), Socket.io 4.8+, uWebSockets.js |
| SSE | Native EventSource, @microsoft/fetch-event-source |
| Managed | Supabase Realtime, Ably, Pusher, PartyKit |
| Scaling | Redis Pub/Sub, NATS, @socket.io/redis-adapter |
| Protocols | WebSocket (RFC 6455), SSE, WebTransport (HTTP/3) |
Architecture Patterns
Scaled WebSocket with Redis Backplane
Client A ââwsâââ Server 1 âââredis pub/subâââ Server 2 âââwsââ Client B
â â
ââââââââ Redis Cluster ââââââââ
Each server subscribes to channels. When Server 1 receives a message
for a room, it publishes to Redis. Server 2 picks it up and forwards
to its connected clients.
SSE with Last-Event-ID Resume
app.get('/events', {
res.(, {
: ,
: ,
: ,
});
lastId = (req.[] || );
missed = eventStore.(lastId);
missed.( {
res.();
});
unsub = eventBus.( {
res.();
});
req.(, unsub);
});