WSChatServer is a lightweight WebSocket chat server implemented from scratch in Java using only standard libraries. It supports multiple concurrent clients and asynchronous message broadcasting. The project includes a simple HTML/JavaScript client for browser-based chatting.
- Multi-client support with asynchronous communication
- Real-time message broadcasting
- Simple HTML/JS web client
- Dockerized setup for easy deployment
.
├── Dockerfile # Dockerfile for the WebSocket server
├── docker-compose.yml # Compose file to run server and client
├── src/
│ └── main/
│ └── resources/
│ └── static/ # HTML/JS client files
└── build.gradle # Gradle build file (if using Gradle)
- Make sure Docker and Docker Compose are installed on your machine.
- Navigate to the project root where
docker-compose.ymlis located. - Build and start the containers:
docker-compose up --build -d- Check running containers:
docker ps- Access the chat client in your browser:
http://localhost
- The WebSocket server runs at:
ws://localhost:8081/socket
- Open multiple browser tabs to
http://localhostto simulate multiple clients. - Type a message in the input box and press Enter or click Send.
- Messages are broadcast to all connected clients in real-time.
- Each client can have a unique color for sent messages.
Chat Client (Single User)
Chat Client (Multiple Users)
- Server uses Java
ExecutorServiceandBlockingQueuefor concurrent handling of clients. - Messages are broadcast asynchronously to all connected clients.
- HTML client is served via a lightweight Nginx container.
Specify your license here (e.g., MIT, Apache 2.0)


