What
Fix "Session ID unknown" errors when Socket.io runs behind a load balancer with multiple server instances.
Why
HTTP long-polling sends separate requests that can land on different nodes — each node maintains its own session store, so the second request finds no matching session ID. Restricting transport to websocket keeps a persistent connection on one node, eliminating the need for sticky sessions.
How
Disable HTTP long-polling, use WebSockets only:
// Client-side
const socket = io({
transports: ["websocket"],
});
WebSockets maintain persistent connection, eliminating the need for sticky sessions.