NestJS · Senior · Question 73 of 75
How do you broadcast WebSocket messages across several Nest instances?
- 1Each instance broadcasts only to its own clients, which is enough
- 2Run only one instance
- ✓Correct answer: Use an adapter backed by a shared channel, e.g. the Socket.IO Redis adapter, and configure sticky sessions if the transport needs them
Explanation
A custom IoAdapter subclass can create the Redis adapter and be set with app.useWebSocketAdapter().