Socket.io Beginner Tutorial - NodeJS + ExpressJS

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ย. 2024
  • In this video I will teach you guys a bit of websockets and how to use socketio in NodeJS and express. I will show you guys how to make a very simple application which exemplifies introductory topics such as receiving and emiting data.
    CDN Script: src="cdn.socket.io/..."
    -
    🚀 Learn ReactJS By Building 6 Projects: codedamn.com/l...
    Please leave a comment on what topic you guys want me to cover next!
    -
    📞 Tutoring Session: www.fiverr.com...
    💻 PedroTech Discord: / discord
    -
    Social
    ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    Website: machadopedro.com
    Twitter: / pedrotech_
    Linkedin: / machadop1407
    Instagram: / _pedro.machado_
    Github: github.com/mac...
    Email: machadop1407@gmail.com
    Tags:
    - Socket.io
    - Fetch
    - ReactJS Tutorial
    - ReactJS and MySQL
    - NodeJS Tutorial
    - API Tutorial

ความคิดเห็น • 135

  • @khangnguyen5538
    @khangnguyen5538 2 ปีที่แล้ว +2

    My boy really made it quick and easy. Thanks, man.

  • @sertansantos3032
    @sertansantos3032 2 ปีที่แล้ว +1

    I love you first tutorial that made me UNDERSTAND IT

  • @tusimegodwin283
    @tusimegodwin283 3 ปีที่แล้ว +5

    Going back to the documentation after watching this video, the get started part makes sense now. Thanks a lot

  • @17Tanner171
    @17Tanner171 3 ปีที่แล้ว +2

    you are a blessing to humanity

  • @shahadatsadhin2849
    @shahadatsadhin2849 3 ปีที่แล้ว +2

    thank you very much I was facing the cors issue before I saw your video😁

  • @realworldcodingapplications
    @realworldcodingapplications ปีที่แล้ว

    watched a bunch of vid coverin the same topic,and actually got client side to work ! whoop tanks for tutorral

  • @1Chitus
    @1Chitus ปีที่แล้ว +1

    Thanx bro , your teaching skill is amazing

  • @thiagogregory1
    @thiagogregory1 3 ปีที่แล้ว +1

    I liked and subbed because you went to school I'm (probably) attending next year here in Brazil. Hope you're doing well there in Canada btw!

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      Awesome! Thanks! So you are you going to study at PASB or UBC?

  • @habib4097
    @habib4097 3 ปีที่แล้ว +2

    Thank you... waiting for your complete chat application tutorial based on React & Node

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      Hey, I actually already have a two video series showing how to do this: th-cam.com/video/XS79S6nmaGM/w-d-xo.html The thing is that the code doesn't work for socket.io current version, but it works for the version 2.3.0 which was the last!

  • @God0fTime
    @God0fTime 2 ปีที่แล้ว +1

    you're a chad bro, their documentation was so confusing

  • @SahityaMahaSagarr
    @SahityaMahaSagarr 3 ปีที่แล้ว +1

    I wanted to live update my game scoreboard now I can by watching this video , thanks !

  • @tens0r884
    @tens0r884 ปีที่แล้ว

    Every few months I have a new tech to learn for whatever project, and every few months my search for answers inevitably leads back me to you. Like that thanos quote

  • @mandeepdaksh376
    @mandeepdaksh376 2 ปีที่แล้ว +1

    Amazing tutorial it was. Seamless, clear, and to the point. 👌😊

  • @maniratnareddy7635
    @maniratnareddy7635 3 ปีที่แล้ว +2

    working fine on localhost but when deployed on heroku its not working...wt changes need to be made?..plz reply

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      Interesting! Maybe socket.io updated and this caused some issues!

  • @ThColinPereira
    @ThColinPereira 3 ปีที่แล้ว +1

    absolute banger, thanks pedroski

  • @BeDb_MeDb
    @BeDb_MeDb 3 ปีที่แล้ว +1

    Thank you, good luck in your next videos and hi from Russia:-)

  • @tricoliciandrei7842
    @tricoliciandrei7842 ปีที่แล้ว

    Golden Man, oh my god. Thank you !

  • @yukaiwu7988
    @yukaiwu7988 2 ปีที่แล้ว

    Thank you man, this video is neat, I learned so much!

  • @expiredlamb2000
    @expiredlamb2000 3 ปีที่แล้ว +3

    Very nicely explained. Now I can finally try to implement some socets into my servers!

  • @BeckettFrey
    @BeckettFrey ปีที่แล้ว

    Nice tutorial helped me out TY!

  • @marimuthumanoj7206
    @marimuthumanoj7206 ปีที่แล้ว

    cool, but what that case of the message should appear in also on sender?

  • @srinivaskurikuri9548
    @srinivaskurikuri9548 2 ปีที่แล้ว

    hai bro this one is helpful can u explain more about the events namespaces and all those

  • @kapilpandit4676
    @kapilpandit4676 2 ปีที่แล้ว

    I want to store messages in local storage after refreshing how to manage previous messages and I want to add the functionality of creating a new room and add joined users in any room

  • @romimaximus
    @romimaximus 3 ปีที่แล้ว +1

    another great tutorial..!!! thankx pedro..👍😎

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      Glad you liked it!

    • @romimaximus
      @romimaximus 3 ปีที่แล้ว +1

      @@PedroTechnologies im just having a hard time connecting the frontend to server, cause the server is refusing my frontend connection..!!! rsss...and is returning a 404 Error...I installed "cors", changed the port number, changed the "socket.io" CDN, but nothing seems to work..!!

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      @@romimaximus some people had this issue too, i will research more on the topic. Im certain that if u downgrade ur socketio version to 2.3 it works, but there most be a way to fix this issue

    • @romimaximus
      @romimaximus 3 ปีที่แล้ว

      @@PedroTechnologies now my server code like this:
      const express = require('express');
      const morgan = require('morgan');
      const app = express();
      const socket = require('socket.io');
      app.set('view engine','ejs');
      app.use(morgan('dev'));
      // @route 'localhost:5000/index'
      app.get('/index', (req,res) => {
      res.render('index');
      });
      const port = process.env.PORT || 5000;
      const server = app.listen(port, () => {
      console.log(`Server running on port localhost:${port}`);
      });
      // CREATE SOCKET
      const io = socket(server);
      //SOCKET CONECTION
      io.on('connection', (socket) => {
      console.log(`User connected on socket: ${socket.id}`);
      });

    • @romimaximus
      @romimaximus 3 ปีที่แล้ว

      now its working....thankx Pedro...!! 👍

  • @oranbenavi8105
    @oranbenavi8105 11 หลายเดือนก่อน

    Great Video Thank you

  • @haiquanzheng5224
    @haiquanzheng5224 3 ปีที่แล้ว +1

    great video!!! i was so confused with the on emit process but you made it clear!!

  • @syedmaroofali7259
    @syedmaroofali7259 3 ปีที่แล้ว +1

    what to do if i want to broadcast my message to a specific person(socket id) ?

  • @mananvirmani1243
    @mananvirmani1243 3 ปีที่แล้ว

    Thanks for this tutorial👍🙂!!

  • @admirdizdarevic7752
    @admirdizdarevic7752 3 ปีที่แล้ว +4

    Hi Pedro. Another great video! Keep it up! I was wondering, can you make a video about Role based access control in react js. It would be very usefull i think.

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      Thank you! I have a video on that using react express and mysql, but I plan on making another one. Here is the video if u are interested: th-cam.com/video/YLihWZwLaGU/w-d-xo.html

    • @admirdizdarevic7752
      @admirdizdarevic7752 3 ปีที่แล้ว

      Thank you! I have watched that one and it help me a lot :D. I was thinking about how can i make that only admin can do registration for example so to specifie if one role can do somth. And that one video really help mee understating some things. Big thanks! You are really great.

  • @vishakamohan5336
    @vishakamohan5336 3 ปีที่แล้ว +1

    that was helpful, thanks!

  • @srujanvemula7973
    @srujanvemula7973 ปีที่แล้ว +1

    good video broo

  • @aniruddhmishra6182
    @aniruddhmishra6182 2 ปีที่แล้ว

    You nailed it brother awesome to-the-point explanation .....the best beginner video for socket io i ve seen

  • @saf_web_genie
    @saf_web_genie 9 หลายเดือนก่อน

    guys nodemon is no longer required after version 18.11 you can use the --watch option

  • @adnanqureshi6098
    @adnanqureshi6098 3 ปีที่แล้ว +1

    I ran client and server on two different ports for the backend and frontend. The problem is that cors is not allowing me to use * the wildcard with the credentials set to true, is there a solution for this problem, i have used socket before but never faced such issue

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว

      If you are running the client and server on different ports, you need to install a dependency called cors. Then require it and use it. Example:
      const cors = require('cors')
      app.use(cors())

    • @adnanqureshi6098
      @adnanqureshi6098 3 ปีที่แล้ว

      @@PedroTechnologies I have used it but still got the same error infact before using socket I was already using cors as a middleware on express

  • @gibraanjafar1669
    @gibraanjafar1669 3 ปีที่แล้ว +1

    Well explained Pedro. Thanks for this wonderful explanation

  • @Shellflower1234
    @Shellflower1234 3 ปีที่แล้ว +1

    Great video bro!

  • @tenureofapps989
    @tenureofapps989 2 ปีที่แล้ว

    Could you please make Restful API's tutorial also?

  • @introvert_Amit
    @introvert_Amit 2 ปีที่แล้ว

    please make a video chat app tutorial

  • @saitejavasamsetti1302
    @saitejavasamsetti1302 3 ปีที่แล้ว

    sir getting error in html that io is not defined i place cdn in script tag after that iam facing error

  • @kalculata555
    @kalculata555 ปีที่แล้ว

    Amazing videos,

  • @realkevinbrian
    @realkevinbrian ปีที่แล้ว

    Awesome content Dude, After 5 years I finally understood about Sockets😅

  • @bassguitarist2686
    @bassguitarist2686 10 หลายเดือนก่อน

    Thank you!

  • @yourjdr
    @yourjdr 2 ปีที่แล้ว

    Make a vedio calling website like zoom without using react js ( or can you do that )

  • @apeiron4409
    @apeiron4409 3 ปีที่แล้ว +1

    great tutorial!

  • @mcspraint4591
    @mcspraint4591 3 ปีที่แล้ว +1

    Brother...it works on my localhost but doesn't work when I host in on a cloud...plz explain why..and how to fix this...

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว

      Interesting, I don't know why that is happening! Maybe socket io changed!

  • @sameeryadav4333
    @sameeryadav4333 3 ปีที่แล้ว

    best channel for web dev, i like your easy and detailed explanations which are very helpful for beginners :)

  • @KT-ut9zg
    @KT-ut9zg 2 ปีที่แล้ว +1

    Great tutorial. Clear and quick.

  • @codexyz97
    @codexyz97 3 ปีที่แล้ว +1

    yes socket io v3 causes issues if you dont set a cors

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      Yes! That made many of my projects outdated, just have to manually set cors for them!

  • @ezequielaguilera130
    @ezequielaguilera130 3 ปีที่แล้ว

    Excelent video thanks!

  • @dochimekashiariri7610
    @dochimekashiariri7610 3 ปีที่แล้ว

    This was really good

  • @zoejmc6230
    @zoejmc6230 5 หลายเดือนก่อน

    bro THANK YOU

  • @krishnajamdhade27257
    @krishnajamdhade27257 2 ปีที่แล้ว

    Thank a lot brother

  • @ahsanijaz3319
    @ahsanijaz3319 2 ปีที่แล้ว

    Really loved this concise way of teaching...

  • @gurvirbaraich2028
    @gurvirbaraich2028 3 ปีที่แล้ว +1

    Thanks!

  • @user-zn5tn9br3b
    @user-zn5tn9br3b 3 ปีที่แล้ว +1

    thx your teaching a lot , I subscribe you ^^ ~~~~ And I want to ask you ,
    12:26 should I change the http to my domain , in the real website app ???? thx a lot

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว

      Thank youy! Yeah, when u deploy you change it to ur websites url!

    • @aw1lt
      @aw1lt 3 ปีที่แล้ว

      @@PedroTechnologies no, thank _youy_

  • @Euquila
    @Euquila 3 ปีที่แล้ว +1

    You are amazing.

  • @TheCodingOdyssey
    @TheCodingOdyssey 3 ปีที่แล้ว +1

    Hey bro! Did you have a good Christmas?

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว

      Yeah bro! Wby? I couldn't even celebrate that much cause of covid and Im studying like crazy for an interview.

    • @TheCodingOdyssey
      @TheCodingOdyssey 3 ปีที่แล้ว

      @@PedroTechnologies Just asking mate! Sorry to hear mate, hope you could at least see your family. I am sure you will crush that interview!

  • @Leo-es3fq
    @Leo-es3fq 3 ปีที่แล้ว +1

    How can i open dropdown menu like the facebook ? I am a beginner in React

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      Hey, I can make a video on that! Probably would be nice to use something like MaterialUI or React Bootstrap!

    • @Leo-es3fq
      @Leo-es3fq 3 ปีที่แล้ว

      @@PedroTechnologies I'm looking forward to your video. I'm using tailwind css

  • @CySA28
    @CySA28 3 ปีที่แล้ว

    i have a problem with user connection. when i start the server it doesn't show the User connection id on terminal 13:28

    • @aw1lt
      @aw1lt 3 ปีที่แล้ว

      same here. did you figure it out?

  • @genosthegreat7870
    @genosthegreat7870 ปีที่แล้ว

    How can i export io to other files?
    Please reply pedro😁😄

  • @f3-faithfitnessfinance
    @f3-faithfitnessfinance 3 ปีที่แล้ว +2

    3000🙌 amazing man🔥

  • @wing-views
    @wing-views 2 ปีที่แล้ว +2

    Hi Pedro, can you please tell why we need to use the http module with express? I am new to node.

  • @taihatranduc8613
    @taihatranduc8613 3 ปีที่แล้ว +1

    you are so good

  • @sudheshanaK
    @sudheshanaK 2 ปีที่แล้ว

    Great video

  • @dalandan8300
    @dalandan8300 2 ปีที่แล้ว

    I followed this one step by step but mine is not updating realtime.

  • @shawngardiner2604
    @shawngardiner2604 3 ปีที่แล้ว

    Very Nice!

  • @random2059
    @random2059 ปีที่แล้ว

    Please reply 🙏🙏🙏🙏🙏
    😢😢😢😢😢😢 please 🙏🙏🙏🙏🙏
    it's very important for my interview
    ......
    why to use low level module like 'http' , when we already have modern 'express'
    , what special inside 'http' module that express can't provide.
    I also saw a stack overflow question pending in this topic
    Please 🙏🙏🙏🙏🙏 reply any body I just need a strong right information 🙏🙏🙏

  • @rufus9322
    @rufus9322 2 ปีที่แล้ว

    very helpful

  • @ccaiuss
    @ccaiuss 2 ปีที่แล้ว

    Nobady toalks about security, login ... i cant use express whitout security !

  • @itshyzen
    @itshyzen 3 ปีที่แล้ว +1

    Nice.

  • @user-iz7fk4eu5t
    @user-iz7fk4eu5t 3 ปีที่แล้ว +1

    Thank from Russa

  • @ThColinPereira
    @ThColinPereira 3 ปีที่แล้ว +1

    do you have a udemy course? i'd totally buy it!

  • @pastasawce
    @pastasawce 3 ปีที่แล้ว

    How can I use socket.io with webpack?

  • @aniruddhmishra6182
    @aniruddhmishra6182 2 ปีที่แล้ว

    i love you bro

  • @ravi6996
    @ravi6996 3 ปีที่แล้ว +1

    Bruh 👌👌

  • @Jeridi
    @Jeridi 2 ปีที่แล้ว

    why .ejs ?

  • @usmanmughal5916
    @usmanmughal5916 3 ปีที่แล้ว +1

    @PedroTech u planning on getting a job?

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      I have a part time job rn, but I am looking for summer internships. I have an interview next week and if all goes well I will accept that one. But Im still in my second year of university so im not looking for anything full time

    • @usmanmughal5916
      @usmanmughal5916 3 ปีที่แล้ว +2

      @@PedroTechnologies I wish u get the internship but I hope u will not stop making video.

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +2

      @@usmanmughal5916 Hahaha no worries! This semester proved to me how much work I can handle at the same time. And since the internship will be during the summer I won't be taking classes. I will structure my day to devote 100% of my time to the internship during the 8 hour shift, then at night I will make videos for the next day!

  • @cyberking4650
    @cyberking4650 3 ปีที่แล้ว

    i need this code

  • @mod7ex_fx
    @mod7ex_fx 2 ปีที่แล้ว

    1111111111111111111111%

  • @rushrush6754
    @rushrush6754 2 ปีที่แล้ว

    Lol this guy reuse the same project a thousand times for every videos.
    So typical of programmers, like what did you do with those seconds saved?

    • @PedroTechnologies
      @PedroTechnologies  2 ปีที่แล้ว

      I never repeat the same tutorial, but I do repeat projects if they are useful for a certain topic. I have a chat app vid using react and this one using vanilla js. This are both targeted for 2 audiences, so I don't see why it would be a problem.

    • @rushrush6754
      @rushrush6754 2 ปีที่แล้ว

      @@PedroTechnologies give back my comment the heart you removed else I will unsubscribe lol

    • @PedroTechnologies
      @PedroTechnologies  2 ปีที่แล้ว +1

      @@rushrush6754 i gave it as an accident hahaha i like constructive comments like urs but i use the heart for when i agree with the comment.

  • @dhawalparmar7117
    @dhawalparmar7117 3 ปีที่แล้ว

    Thanx bro , your teaching skill is amazing

  • @easywebdevelopment
    @easywebdevelopment 2 ปีที่แล้ว +1

    Amazing tutorial it was. Seamless, clear, and to the point. 👌😊