WebSockets with NodeJS (Express) and WebSocket API

Поделиться
HTML-код
  • Опубликовано: 13 май 2020
  • How to set up a WebSockets Client and Server and Connect them!
    -------------------------------------
    Code: github.com/Vuka951/tutorial-c...
    WebSocket API:
    * developer.mozilla.org/en-US/d...
    * developer.mozilla.org/en-US/d...
    WS (WebSocket): www.npmjs.com/package/ws
    --------------------------------------
    Thanks for watching, if the video was helpful to you a like and/or a star to the github repo would be appreciated ❤️

Комментарии • 57

  • @KeiAKWs
    @KeiAKWs 7 месяцев назад +3

    Spent the whole day today to follow a 2 hours turorial on a web-socket-application and it didn't work, and I could't find the bug. And it felt like I didn't even understand what exactly I was coding on each line. This helped me capture it better. Thank you.

  • @PabloGnesutta
    @PabloGnesutta 3 года назад +26

    This is SO GREAT man. Exactly the amount of data necessary and the amount of pointing where to find out more. Great flow, very dense in information.
    Thank you.

  • @SkanRideAdmin
    @SkanRideAdmin Год назад +1

    I was struggling to get some concise guideline on this as an entry level coder and you made my day.

  • @involuntaryoccupant
    @involuntaryoccupant 4 года назад +19

    After 4 days of torture I finally find your video. Simple and easy. You are the best, man.

    • @vuka951
      @vuka951  4 года назад +4

      Glad it was helpful!

  • @tudorstanciulescu9914
    @tudorstanciulescu9914 3 года назад +3

    bro, finally someone who explained this websocket communication right for beginnerrs. Thx a lot! u saved my project

  • @jensvandenberghe3762
    @jensvandenberghe3762 8 месяцев назад

    I've have been looking for an explanation on how to use websockets for 5 hours. I've been losing my mind about the amount of unclear explanations there were. You just saved my day and also my sanity. Thank you

  • @distinguishedy
    @distinguishedy 3 года назад

    Thanks man, this simple explanation really helped with cramping websockets into my vue project.

  • @HermanRas
    @HermanRas 2 года назад

    Huge thanks ! this was exactly what I needed !
    the very bare bones approach to WS.

  • @swag2315
    @swag2315 Год назад

    thanks bro I overcomplicated things but this really helped me understand

  • @proengineer4250
    @proengineer4250 3 года назад

    You are awesome, amazing and marvelous. This is a fantastic tutorial.

  • @gaurangvishnoi8995
    @gaurangvishnoi8995 2 года назад

    wow... that was smooth... it will help me tomorrow but thank you today.

  • @user-dc7oj3el7o
    @user-dc7oj3el7o 3 года назад

    Have been so much help, thanks a lot!

  • @tathagat9586
    @tathagat9586 Год назад

    Thank you, great work. It's very helpful

  • @maurinoferreira6184
    @maurinoferreira6184 2 месяца назад

    How isn't possible leave more than one like on this awsome video ?

  • @magickomchanell4556
    @magickomchanell4556 5 месяцев назад

    Before recording, I suggest increasing your vscode font to 17-20, it will really help us, thank you

  • @bryandandan5443
    @bryandandan5443 2 года назад +2

    Great tutorial. One question though, how can you send to specific client?

  • @SachinABS
    @SachinABS Год назад

    very clear explanation.

  • @GiulioAndCode
    @GiulioAndCode 2 года назад

    Thanks, great video!🔥 I use this in future video tutorial in my yt channel

  • @prashantdhawase8057
    @prashantdhawase8057 3 года назад

    very nice video short sweet and explained very well thanks :)

  • @garrin5922
    @garrin5922 2 года назад +3

    Websocket Update: Add another parameter, in ws.on('message'... called isBinary for sending to other clients excluding itself because they will be encrypted if I'm not mistaken. Kinda like this
    ws.on('message', function message(data, isBinary) {
    wss.clients.forEach(function each(client) {
    if (client !== ws && client.readyState === WebSocket.OPEN) {
    client.send(data, { binary: isBinary });
    }
    });

  • @eqisoftcom
    @eqisoftcom 4 года назад

    Very useful, thank you!

    • @vuka951
      @vuka951  3 года назад

      Glad to hear that!

  • @HarshaSagarKV
    @HarshaSagarKV Год назад

    Helped a Lot !!!!!

  • @tudorstanciulescu9914
    @tudorstanciulescu9914 3 года назад

    For example if i want to send some data from server to client, but in a custom event. on the server side, in connection event i need to send the event, like
    wss.on('connection', function connection(ws){
    ws.send('myCustomEvent', someData);
    });
    and in the client side i just need to add an event listener to receive that custom event?
    socket.addEventListener('myCustomEvent', (data) => {
    console.log(data.data)
    })

  • @johnyepthomi892
    @johnyepthomi892 3 года назад

    bingo you’re awesome dude!

  • @ShaneBoiGaming
    @ShaneBoiGaming 7 месяцев назад

    I like the console group chart!

  • @yashpreetbathla4653
    @yashpreetbathla4653 3 года назад +3

    amazing man thanks alot :)

    • @vuka951
      @vuka951  3 года назад +1

      Glad it helped!

  • @nicetomeetugaming7024
    @nicetomeetugaming7024 2 года назад

    Thanks a lot sir!

  • @lavoe574
    @lavoe574 3 года назад +2

    How do you use the same express port in ws?

  • @programmerjadul2648
    @programmerjadul2648 3 года назад +1

    how to authentication and authorization using jwt in websocket ws

  • @rizzy5652
    @rizzy5652 2 года назад

    Nice video thanks

  • @bprincepandey
    @bprincepandey 2 года назад

    great video

  • @jeetchheda8916
    @jeetchheda8916 Год назад

    Can We Uniquely Identify this client ? And Do some Action based on which client closed the Connection ??

  • @AfroDemoz
    @AfroDemoz Год назад

    wooooooza i like hardcore codding thou I am not that good so keep the good vibe going

  • @harymk
    @harymk 3 года назад

    how can use this method to firebase web hosting

  • @normajeanchariot
    @normajeanchariot 3 года назад +2

    why do you have to open the file directly? I want to navigate to port 3000 not open file with browser. I copied example from npm ws word for word and then copied the websocket browser example from mozilla developer word for word and it doesnt work. My browser goes into infinite load.

    • @ramsantosh6268
      @ramsantosh6268 2 года назад

      did you find the solution for opening the page in localhost:3000 (any port number)

  • @bigbadcatbigbcy2933
    @bigbadcatbigbcy2933 4 месяца назад

    good video

  • @AjayKumar-pl5st
    @AjayKumar-pl5st Год назад

    i tried the same code but in client side instead of showing hello from client1 its showing blob{size:19 type:" "} if u know how to solve the issue kindly let me know

  • @axeleli6845
    @axeleli6845 3 года назад

    thank you

  • @mfAdvice
    @mfAdvice 10 месяцев назад

    Sir my websocket url require authentication how to connect. Please share some code or video

  • @prenomnom5637
    @prenomnom5637 3 года назад +1

    good video. it could have been better if you used a bigger font, but great video anyways.

  • @chihabahmed5207
    @chihabahmed5207 3 года назад

    how do you save all connections
    I know when the user make a connection we can have an array such as const user = []
    then we push each socket and user id from our front end, in case someone logs in to our server with jwt and gets the his user profile such as { id: xxxx, name: asss, email:add@hotmail.com}
    so we can push the user id or his email (unique) to that array along side the socket correct.
    can we store them in redis and if a connections is lost we can update that socket in redis ? or how do you go about implementing this
    thanks

  • @mohammedelghazal6077
    @mohammedelghazal6077 2 года назад

    How can use it in real server hosting ??

  • @lutfiikbalmajid3128
    @lutfiikbalmajid3128 2 года назад +1

    i like for the topics and explanation, i dislike for readibility, the text to small, you need to zoom it later

  • @dhawalparmar7117
    @dhawalparmar7117 2 года назад +3

    Next time please increase font size

  • @rodrigocardoso126
    @rodrigocardoso126 29 дней назад

    I need help

  • @ramadanmusa3116
    @ramadanmusa3116 Год назад

    hello friend..i get the error when running a node index.js file
    const wss = new WebSocket.Server({ server:server });
    ^
    TypeError: WebSocket.Server is not a constructor

  • @zsar_official
    @zsar_official 3 года назад +1

    What is the difference between ws and websocket ?? I'm really confused

    • @nclsDesign
      @nclsDesign 3 года назад +3

      Two different libraries but both with the dame basic function

    • @zsar_official
      @zsar_official 3 года назад

      @@nclsDesign I figured, in a month

    • @thenextbigthing1393
      @thenextbigthing1393 2 года назад

      @@nclsDesign I think its not dame.

    • @nclsDesign
      @nclsDesign 2 года назад

      @@thenextbigthing1393 Not the same but the SAME BASIC FUNCTION, as I said.

  • @heitormbonfim
    @heitormbonfim 2 года назад +1

    Bruh, next time add some zoom, I can't see that well