Node.js FAQ: Top Questions
31. What are WebSockets in Node.js?
WebSockets in Node.js enable bidirectional, real-time communication between a client and server over a single, persistent connection, ideal for applications like chat or live updates.
Key points:
- Protocol: Upgrades HTTP to WebSocket (ws:// or wss://).
-
Libraries:
ws
(popular),Socket.IO
(higher-level). - Features: Low latency, event-driven messaging.
- Use Case: Real-time apps (e.g., notifications, gaming).