Wrong Room

A chat backend runs three identical WebSocket nodes behind a load balancer, each holding an in-process map of user id to socket. Users on the same node see each other's messages instantly, but a message from a user on node 1 never reaches a recipient connected to node 3. What is the fix?

A

Have clients open an SSE stream instead of a WebSocket, so the server rather than the client decides when each message is delivered

B

Publish every message onto a shared pub/sub backplane that all nodes subscribe to, so the node holding the recipient delivers it

C

Turn on sticky sessions at the load balancer so every user is routed back to the node that already holds their socket

D

Shorten the heartbeat interval so stale entries in each node's socket map are evicted before a send is attempted against them