socketio
/socketio
Socket.IO 4.x covering namespaces, rooms, acknowledgements, adapters, scaling, connection state recovery, middleware, TypeScript types, and multi-server deployment. Use for \"Socket.IO\", \"socket.io\", \"rooms\", \"namespaces\", \"Socket.IO adapter\", \"Redis adapter\", \"Socket.IO scaling\", \"Socket.IO middleware\", \"Socket.IO authentication\", \"Engine.IO\", \"Socket.IO reconnect\", \"emitWithAck\", \"Socket.IO admin\", \"connection state recovery\", \"volatile emit\", \"Socket.IO TypeScript\".
- Author
- chrishuffman5 ↗
- Repository
- domain-expert ↗
- Licence
- MIT
- Last repository change
- 23.09.2026
Assessment and security
- Files in this package
- 4
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 23.09.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Socket.IO 4.x covering namespaces, rooms, acknowledgements, adapters, scaling, connection state recovery, middleware, TypeScript types, and multi-server deployment. Use for \"Socket.IO\", \"socket.io\", \"rooms\", \"namespaces\", \"Socket.IO adapter\", \"Redis adapter\", \"Socket.IO scaling\", \"Socket.IO middleware\", \"Socket.IO authentication\", \"Engine.IO\", \"Socket.IO reconnect\", \"emitWithAck\", \"Socket.IO admin\", \"connection state recovery\", \"volatile emit\", \"Socket.IO TypeScript\".
Triggers from the description
Original author description
Socket.IO 4.x covering namespaces, rooms, acknowledgements, adapters, scaling, connection state recovery, middleware, TypeScript types, and multi-server deployment. Use for \"Socket.IO\", \"socket.io\", \"rooms\", \"namespaces\", \"Socket.IO adapter\", \"Redis adapter\", \"Socket.IO scaling\", \"Socket.IO middleware\", \"Socket.IO authentication\", \"Engine.IO\", \"Socket.IO reconnect\", \"emitWithAck\", \"Socket.IO admin\", \"connection state recovery\", \"volatile emit\", \"Socket.IO TypeScript\".
How it works
- How to Approach Tasks
- Core Architecture
- Anti-Patterns
- Reference Files
- Cross-References
SKILL.md preview
---
name: socketio
description: "Socket.IO 4.x covering namespaces, rooms, acknowledgements, adapters, scaling, connection state recovery, middleware, TypeScript types, and multi-server deployment. Use for \"Socket.IO\", \"socket.io\", \"rooms\", \"namespaces\", \"Socket.IO adapter\", \"Redis adapter\", \"Socket.IO scaling\", \"Socket.IO middleware\", \"Socket.IO authentication\", \"Engine.IO\", \"Socket.IO reconnect\", \"emitWithAck\", \"Socket.IO admin\", \"connection state recovery\", \"volatile emit\", \"Socket.IO TypeScript\"."
license: MIT
---
# Socket.IO 4.x
This skill covers Socket.IO 4.x (latest stable: 4.8.x), the real-time communication library built on Engine.IO. Socket.IO is NOT a WebSocket wrapper -- it is a higher-level protocol with its own features. It has deep knowledge of:
- Engine.IO transport layer (HTTP long-polling upgrade to WebSocket)
- Namespaces (multiplexed communication channels)
- Rooms (server-side broadcast groups)
- Acknowledgements and `emitWithAck` (request/response pattern)
- Connection state recovery (v4.6+)
- Middleware system (connection, packet, namespace)
- Adapter system for multi-server scaling (Redis, Redis Streams, Postgres, MongoDB, Cluster)
- TypeScript event typing
- Admin UI for monitoring
## How to Approach Tasks
1. **Classify** the request:
- **Architecture / core features** -- Load `references/architecture.md` for Engine.IO, namespaces, rooms, events, recovery
- **Scaling / best practices** -- Load `references/best-practices.md` for adapters, sticky sessions, middleware, TypeScript, Admin UI
- **Troubleshooting** -- Load `references/diagnostics.md` for connection issues, room broadcasting, adapter problems, performance
- **Cross-technology comparison** -- Read the `overview` skill
2. **Gather context** -- Socket.IO version, runtime (Node.js, Deno, Bun), adapter in use, scaling approach, client platform
3. **Analyze** -- Apply Socket.IO-specific reasoning: namespace isolation, room lifecycle, adapter propagation, transport upgrade.
4. **Recommend** -- Provide server and client JavaScript/TypeScript code, adapter configuration, infrastructure setup.
## Core Architecture
### Engine.IO Transport Layer
Engine.IO always starts with HTTP long-polling, then upgrades to WebSocket. Heartbeat: server sends `ping` every 25s; client responds with `pong` within 20s.
### Key Distinction
Socket.IO requires matching client/server libraries. A raw WebSocket client cannot connect to a Socket.IO server.
### Namespaces
```javascript
const adminNsp = io.of("/admin");
adminNsp.on("connection", (socket) => { /* ... */ });
```
Each namespace has independent event handlers, rooms, and middleware.
### Rooms
Server-side only broadcast groups:
```javascript
socket.join("room1");
io.to("room1").emit("event", data);
socket.to("room1").emit("event", data); // excludes sender
```
### Acknowledgements
```javascript
const result = await socket.timeout(5000).emitWithAck("create:user", data);
```
### Connection State Recovery (v4.6+)
```javascript
const io = new Server(httpServer, {
connectionStateRecovery: { maxDisconnectionDuration: 2 * 60 * 1000 }
});
```
Restores socket ID, rooms, and missed packets after brief disconnection.
## Anti-Patterns
1. **Using namespaces as rooms** -- They serve different purposes. Namespaces separate concerns; rooms group connections within a namespace.
2. **No sticky sessions with long-polling** -- Multi-server without sticky sessions causes HTTP 400 "Session ID unknown" errors.
3. **Not handling the non-recovered case** -- Connection state recovery can fail. Always implement the fallback path.
4. **Forgetting `next()` in middleware** -- Connection hangs until timeout if `next()` is not called.
5. **Creating too many static namespaces** -- Use dynamic namespaces for per-entity isolation.
6. **Not accessing `socket.rooms` in `disconnecting` event** -- In `disconnect` event, `socket.rooms` is already empty. Use `disconnecting` to read rooms before cleanup.
7. **Using `forceNew: true` unnecessarily** -- Disables multiplexing, creating separate WebSocket connections per namespace.
8. **No adapter for multi-server** -- Without an adapter, broadcasts only reach clients on the local server.
## Reference Files
- `references/architecture.md` -- Engine.IO transport, namespaces, rooms, events, acknowledgements, binary, connection state recovery, middleware
- `references/best-practices.md` -- Adapter selection, scaling patterns, sticky sessions, TypeScript typing, Admin UI, room management patterns, authentication
- `references/diagnostics.md` -- Connection failures, room broadcast issues, adapter problems, sticky session errors, performance, upgrade issues
## Cross-References
- `overview` skill -- Socket.IO vs SignalR, WebSocket, SSE comparisons
- `websocket` skill -- Raw WebSocket protocol (Socket.IO builds on top)
Files in this package (4)
- SKILL.md 5 KB
- references/architecture.md 5 KB
- references/best-practices.md 6 KB
- references/diagnostics.md 6 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · chrishuffman5/domain-expert | 100 | MIT |
| TerminalSkills/skills | 100 | Apache-2.0 |
Database snapshot: 13.11.2026 · package version 6d2972c88b27 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100socket-io
Socket.IO real-time bidirectional communication. Rooms, namespaces, acknowledgments, middleware, scaling with Redis adapter, and TypeScript types. USE WHEN: user mentions "Socket.IO", "socket.io", "real-time chat", "live updates", "bidirectional WebSocket", "rooms", "namespaces"… - 100nestjs-websocket
WebSocket integration for NestJS using Socket.IO. Covers gateways, rooms, authentication guards, exception filters, and Redis adapter for scaling. USE WHEN: user mentions "NestJS WebSocket", "NestJS gateway", "Socket.IO NestJS", "real-time NestJS", "NestJS chat", "WebSocket… - 100websocket-engineer
Use when building real-time communication systems with WebSockets or Socket.IO. Invoke for bidirectional messaging, horizontal scaling with Redis, presence tracking, room management. - 90backend-websocket-patterns
Use this skill when the user says 'WebSocket', 'real-time', 'socket.io', 'WS connection', 'reconnection', 'WS rooms', 'broadcast', 'WS scaling', 'WS clustering', 'pub/sub over WS', 'SSE', 'Server-Sent Events', 'long polling', 'WS handshake', or when designing real-time… - 100websocket-engineer
Use when building real-time communication systems with WebSockets or Socket.IO. Invoke for bidirectional messaging, horizontal scaling with Redis, presence tracking, room management. - 90cmux-socket-policy
Socket command threading and focus policy for cmux CLI/socket work. Use when adding or changing socket commands, CLI commands, telemetry commands, focus/select/open/close/send-key behavior, or automation that could steal app focus.