A simple real-time chat application with two different ways to communicate: Long Polling and WebSocket. It also supports likes and dislikes feature.
The goal of this project was to understand the difference between those approaches by building it ourselves.
Both implementations are located on one branch in a corresponding folder with independent package.json and frontend
- Runtime environment: Node.js
- Packages: cors, websocket, express.
The frontend sends a request to the backend every second to check for new messages.
The frontend maintains a persistent connection, allowing the backend to push updates instantly when new messages arrive.
This setup highlights the performance and efficiency differences between the two approaches.
cd long-polling/backend
npm install
node backend.js- open
client.jsin your browser
cd websocket/backend
npm install
node backend.js- open
client.jsin your browser
- Understand client-server communication
- Compare real-time communication strategies
- Learn WebSocket fundamentals
- Learn long polling trade-offs