Hey gang, in this WebSockets tutorial, I’ll show you how we can broadcast messages to every client EXCEPT the one that initially sent the message to the server. This is in contrast to emitting messages from the server – which emits to every single client INCLUDING the client that originally sent the message.

+ Repo –
+ Atom editor –
+ Download Node –
+ –
Related tutorials:



============== The Net Ninja =====================

For more front-end development tutorials & to black-belt your coding skills, head over to – or

================== Social Links ==================

Twitter – @TheNetNinja –


  1. I know this is a demo for sockets and not a tutorial on how to build a chat app but if you add:

    // Emit Events
    message.addEventListener('keyup', function() {
    if (message.value.length === 0) {
    console.log('cancel-typing', message.value.length);
    } else {
    socket.emit('typing', handle.value);
    console.log('typing', message.value.length);


    socket.on('cancel-typing', function(data) {
    feedback.innerHTML = "";

    to the chat.js file then add

    socket.on('cancel-typing', function() {

    to the index.js file it will clear the feedback screen if someone erases their message without sending. I'm a beginner and was happy I could figure that out so I thought I would share.

  2. I do have one tho, what determines what client receives the message. Are why do the the other 2 clients receive the typing msg and not all 3 like the chat message does.

  3. Wonderful… Just wonderful
    I don't know why I've purchased series of tutorial on Udemy and pluralsight…
    Since that moment done, i declare YouTube my favorite online training platform

  4. Shaun, have you ever thought of creating lessons and putting it on Udemy? I have paid for far worse lessons before on Udemy, these lessons of yours will sell like hot cakes my friend, each and every one of your lessons are AWESOME..!!! thank you for all your hard work and sharing with all of us.

  5. Best tutorial easy to learn , Sir Can you made a video on WEBRTC RTCPEERCONNECTION STUN, TURN and SIGNALING (ONE TO ONE VIDEO CONFERENCING)

  6. Жаль что не увидел этот гайд раньше, единственное что бы хотелось узнать поподробнее, это билдинг такого сервера

  7. As a subscriber tp Lynda, I was looking to find way of setting up a node.js script for a chat to run of a different server, I could not work it out, until I followed your tutorial. I have to say I know most of what you were saying, but I was just stuck on the last key piece to get it too work running the client from a remote server to access the node script running on my localhost, and got it working fine. What the final issue was that the server when I am running my server side script is LAMP, and the hosting does not have the capacity to run node.js. Someone suggested to me to use Heroku as a server to host my node application. After a lot screaming trying to get it to work I found This which maybe some use to anyone who can't host node for their app

  8. So cool.. Could you please help me in publishing my chat app over web to my friends… I am happy any way, with your videos.. I would be glad if it is over the Web….???????

  9. Dear The Net Ninja, I guess we are having some issues when we are trying to deploy this on Heroku. Simply, it doesn't work there even though it's working perfectly on local. What should we do? Can you make a tutorial for deploying as well, because there is some weird logical mistake when we are trying to deploy it.

  10. awesome tutorial buddy 🙂

    if someone want to make "is typing a message…" disappear when u stop typing then –
    1.Add this eventlistener to chat.js –

    //called when user focus away from inputfield or presses enter

    2.Add this to chat.js –


    3.Add this to callback of io.on() in index.js –

    socket.on('typingstop', function(){

  11. An excellent tutorial. You must be a teacher by profession. I Love that you answer my questions before I can ask them. I have subscribed to your channel and will be watching your other tutorials. I would love a tutorial on calculus that gets straight to the point and explains the things I need to know along the way like you do.

  12. Hey! Great web Socket tutorials. I have implemented one web socket page for share market candle stick chart for one of my personal studies. could you please tell me how do i connect with server like NSE India stock market? what i want when market start, immediate read stock price each second and store it to my database for future use? could you please show me how to do that? Please……….:)


Please enter your comment!
Please enter your name here