WebSocket is a full-duplex communication protocol over a single TCP protocol. The WebSocket protocol enables interaction between a web browser (or other client application) and a web server with lower overhead than half-duplex alternatives such as HTTP polling, facilitating real-time data transfer from and to the server.
Clone a copy of the repo:
git clone https://github.com/NagaraniG/nodejs-websocket.git
Change to the nodejs-websocket directory:
cd nodejs-websocket
node web-socker-server.js
now double click on websocket.html
For seeing chat response kind please open your websocket.html in different windows and minimize it keep it all in one window you can see a response like below screenshots
Have a look at WebSocket Implementation in NodeJS for reference