// the find
rajaraodv/redispubsub
A Node.js chat app using Express, Redis Pub/Sub + Redis SessionStore + Socket.io + Socket.Sessions that shows scaling on Cloud foundry
A demo chat app from 2013 that shows how to scale Socket.io across multiple Node.js instances using Redis for both session storage and pub/sub. It was written for Cloud Foundry and targets the specific problem of sticky sessions breaking after a server restart. The README is actually a pretty good tutorial on the problem space.
The reconnection strategy — disabling Socket.io's built-in reconnect and rolling a custom HTTP ping to re-establish jsessionid before reconnecting the socket — is a real solution to a real problem that bit a lot of people. The explanation of why sticky sessions fail after a restart (new IP/port, old cookie is stale) is clear and accurate. Session regeneration on index load to avoid stale jsessionid binding is a correct and non-obvious fix. The diagrams in the README make the architecture easy to follow.
This is a nine-year-old snapshot targeting Cloud Foundry with vmc, Express 3.x session middleware, and a Socket.io version that no longer exists in this form — none of it runs as written today. The pub/sub implementation has a classic bug: a new Redis subscriber listener is attached inside the connection event, so each connected socket adds another `sub.on('message')` handler, meaning messages get broadcast N times to each client as connections accumulate. The whole custom reconnect hack is unnecessary with modern Socket.io (which has proper reconnection with exponential backoff and the adapter pattern via `socket.io-redis` / `@socket.io/redis-adapter` that replaces all of this). Worth reading as history, not as a template.