Chat Example
A simple chat demo using multiple Socket.IO servers
Features
- Multiple users can join by entering an username on website load
- Users can type chat messages
Built with
Server
Web
Environment Variables
Server
Variable | Default | Type | Desc | Example |
---|---|---|---|---|
DEBUG | --- | string | node.js debugging utility | socket.io:server* |
NODE_ENV | development | string | can be "production" or "development" or "test" | development |
PORT | 3001 | number | server/listening port | 3001 |
REDIS_HOSTS | --- | json array as string | redis cluster host/port list | '[{"host":"localhost","port":6101}]' |
REDIS_PASSWORD | --- | string | redis cluster password | pwd |
HOSTNAME | APP_DEFAULT | string | OS or Container hostname | MY_PC |
CORS_ORIGIN | http://localhost:3000 | string | web app url | http://localhost:3000 |
Web
Variable | Default | Type | Desc | Example |
---|---|---|---|---|
REACT_APP_SOCKET_ENDPOINT | --- | string | socket server endpoint | http://localhost:3001 |
How to use
$ docker-compose up --scale socket-server=3 -d
It starts Redis cluster, Traefik for reverse-proxy, web app and 3 socket.io servers.
And point your browser to http://localhost:3000.
Screenshot
![]() |
![]() |