From Beginner to Advanced
Introduction
Chapter 1: Why Real-Time Matters and Why HTTP Falls Short
- The Request-Response Model and Its Limits
- Problems HTTP Cannot Solve Well
- What Real-Time Communication Enables
- Use Cases Across Modern Applications
- Choosing Between Real-Time and Polling
Chapter 2: Bridging the Gap: Polling, Long Polling, and Server-Sent Events
- Short Polling and Its Costs
- Long Polling Mechanics and Trade-offs
- Server-Sent Events (SSE) Protocol
- SSE versus WebSockets: When Each Fits
- Why Fallback Strategies Still Matter
Chapter 3: The WebSocket Protocol Deep Dive
- The WebSocket Handshake Process
- Frame Structure and Opcodes
- Connection Lifecycle in WebSockets
- Binary versus Text Data
- Limitations of Raw WebSockets in Practice
Chapter 4: Engine.IO and the Socket.IO Architecture
- Why Socket.IO Is Not Just a WebSocket Wrapper
- Engine.IO: The Low-Level Transport Layer
- Transport Upgrade Flow in Practice
- How Socket.IO Adds Reliability on Top
- Architectural Diagram and Data Flow
Chapter 5: Your First Real-Time Application
- Project Setup and Installation
- Building the Server in JavaScript
- Connecting a Browser Client
- Running Your First Real-Time App
Chapter 6: Connection Lifecycle and Event Mechanics
- The Connection State Machine
- Disconnect Events and Graceful Shutdown
- Reconnection Logic and Configuration
- Acknowledgements: Request-Response over Events
- Timeouts and Error Handling Patterns
Chapter 7: Namespaces, Rooms, and Targeted Communication
- Namespaces for Logical Separation
- Rooms for Dynamic Grouping
- Broadcasting Patterns and Selectors
- Designing Communication Topologies
- Common Mistakes with Rooms and Namespaces
Chapter 8: Middleware, Authentication, and Authorization
- Middleware in the Connection Pipeline
- Token-Based Authentication Patterns
- Session Management and Cookies
- Authorization: Controlling Access by Role
- CORS Configuration for Socket.IO
Chapter 9: Configuration, Binary Data, and Advanced Client/Server Options
- Server-Side Configuration Reference
- Client-Side Configuration Reference
- Sending Binary Data and Buffers
- File Transfer Patterns over Socket.IO
- Compression and Performance Tuning
Chapter 10: Presence Systems, Status, and Notifications
- Implementing a Presence System
- Online/Offline Status Tracking
- Typing Indicators and Activity Signals
- Push Notifications with Socket.IO
- Recovering Connection State After Reconnect
Chapter 11: Chat Applications: From Basic to Production-Grade
- Basic Real-Time Chat Room
- Private Direct Messaging
- Group Chats with Rooms
- Typing Indicators and Read Receipts
- Persisting Messages to a Database
Chapter 12: Live Dashboards, Collaborative Apps, and Real-Time Feeds
- Live Data Dashboards and Metrics
- Building a Real-Time Feed or Ticker
- Collaborative Editing Patterns
- Multiplayer Game Communication Loops
- IoT Telemetry and Device Streams
Chapter 13: Horizontal Scaling with Redis, Adapters, and Clustering
- Why Single-Process Deployment Hits a Wall
- The Redis Adapter Architecture
- Sticky Sessions and Load Balancers
- Clustering with Node.js cluster Module
- Message Queues for Pub/Sub at Scale
Chapter 14: Security, Testing, Monitoring, and Deployment
- Security Threats and Mitigations
- Input Validation and Sanitization
- Rate Limiting Strategies
- Logging, Monitoring, and Observability
- Debugging Socket.IO Applications
- Automated Testing and Integration Tests
- Reverse Proxies and TLS Termination
- Docker Deployment Patterns
- Cloud Deployment and Reliability