WebSockets Crash Course - Handshake, Use-cases, Pros & Cons and more

  Рет қаралды 273,273

Hussein Nasser

Hussein Nasser

Күн бұрын

WebSockets technology is a bidirectional, full-duplex protocol for communication between client and server over the web. It has been standardized in 2011 and its fully compatible with HTTP. This protocol enables realtime applications such as chatting, notifications, live feed , multiplayer gaming and otheruse cases.
In this video we will explain what WebSockets are and why it was invented. we will then build a server and client using WebSockets. We will also talk about the pros and cons of WebSockets, and discuss some alternatives to this technology
Chapters
0:00 Intro
2:00 HTTP
5:40 WebSockets
8:00 WebSockets Handshake
11:20 WebSockets Usecases
14:30 WebSockets Example Code
36:40 WebSockets Pros and Cons
42:10 Do you have to use webSockets?
Source Code in the video for WebSockets
github.com/hnasr/javascript_p...
HTTP
* talk about request-response show a slide. Client initiate request all the time. Imagine building a chatting app?
WebSockets
- Slide showing bidrectional full duplex standard web
-
How WebSockets Work?
- WebSockets handshake
- Initial request is always HTTP which we all know creates a tcp connection, that request then http upgrade tells the server to use it as bidirectional.
- Once done switches to binary protocol.
- Ws:// wss:// protocol
WebSocket use cases
- Chatting
- Live feeds
- Multiplayer gaming
- Progress bar/ logging/ uploading..
- WebSockets example (Server/Client)
- WebServers Pros and Cons
Pros
1. Full-duplex no need for constant polling
2. compatible with HTTP, so proxies know to deal with it
3. Firewalls won’t block it doesn’t use a special port
Cons
1. Proxying is tricky, lots of proxies and transparent proxies don’t support it yet
2. Layer 7 load balancing is tricky, timeouts on the load balancer.
3. More complicated to implement (simple telnet use HTTP)
4. Not ideal for all use cases - (microservices)
- Do you have to use Web Sockets ? ( alternatives )
It is important to note that WebSockets is not the only HTTP realtime based solution, there are other ways to achieve real time such as eventsource, and long polling.
- Load Balancing with WebSockets (bonus)
- layer 4
- Layer 7 (tunnel)
Longpolling
Eventsource
WebSockets
Sources:
developer.mozilla.org/en-US/d...
www.ably.io/concepts/websockets
/ ljssosnw6y
blog.stanko.io/do-you-really-...
Cards
HTTP Crash Course • Hyper Text Transfer Pr...
TLS • Transport Layer Securi...
What is a Web Servers • What are web servers a...
Layer 4 vs Layer 7 Load Balancing • Load balancing in Laye...
Support my work on PayPal
bit.ly/33ENps4
Become a Member on KZbin
/ @hnasr
🧑‍🏫 Courses I Teach
husseinnasser.com/courses
🏭 Backend Engineering Videos in Order
backend.husseinnasser.com
💾 Database Engineering Videos
• Database Engineering
🎙️Listen to the Backend Engineering Podcast
husseinnasser.com/podcast
Gears and tools used on the Channel (affiliates)
🖼️ Slides and Thumbnail Design
Canva
partner.canva.com/c/2766475/6...
🎙️ Mic Gear
Shure SM7B Cardioid Dynamic Microphone
amzn.to/3o1NiBi
Cloudlifter
amzn.to/2RAeyLo
XLR cables
amzn.to/3tvMJRu
Focusrite Audio Interface
amzn.to/3f2vjGY
📷 Camera Gear
Canon M50 Mark II
amzn.to/3o2ed0c
Micro HDMI to HDMI
amzn.to/3uwCxK3
Video capture card
amzn.to/3f34pyD
AC Wall for constant power
amzn.to/3eueoxP
Stay Awesome,
Hussein

Пікірлер: 339
@hnasr
@hnasr 4 жыл бұрын
Guys Jump codes for your convenience, HTTP 2:00 WebSockets 5:40 WebSockets Handshake 8:00 WebSockets Usecases 11:20 WebSockets Example Code 14:30 WebSockets Pros and Cons 36:40 Do you have to use webSockets? 42:10 Stay awesome!
@josepetoshi8135
@josepetoshi8135 4 жыл бұрын
Greate course mate!
@thanasisathanasi4965
@thanasisathanasi4965 4 жыл бұрын
Man, every part of your video is really for us. Very well documented and comprehensive! The best I could find./
@TheDroiDGch
@TheDroiDGch 3 жыл бұрын
The best channel about computer science!! thank you so much for these wonderful and helpful videos!
@reinohaider4239
@reinohaider4239 3 жыл бұрын
I need your help.. I need project for MSc computer network guys can any one help me!
@computeering
@computeering 3 жыл бұрын
Can you please make a comprehensive video about keeping track of clients using Websockets?
@truphenalwanga9829
@truphenalwanga9829 4 жыл бұрын
I always like it when a channel has the perfect balance of comedy and education. Subscribed! Great stuff!
@hnasr
@hnasr 4 жыл бұрын
Truphena Lwanga thanks ! Yeah hard to keep the balance. Do tell me if it gets little much. Any feedback helps. Enjoy the content. Cheers
@langsonchibili1329
@langsonchibili1329 4 жыл бұрын
THE FIRST 5 MINUTES INTO YOUR VIDEO MADE ME UNDERSTAND OVER 3 YEARS WORTH OF INFORMATION, U ARE A BLESSING Hussein Nasser
@TheDesvendador
@TheDesvendador 4 жыл бұрын
I cant believe i found this channel, this kinda of content is gold, please keep it up, also gonna watch that one about nodejs and webservers
@hnasr
@hnasr 4 жыл бұрын
Thanks! Very happy your enjoying the content
@parmvirsidhu7563
@parmvirsidhu7563 3 жыл бұрын
I loved the way you start with WHY? then reasoning, when to use and when not to use, very practical approach to all the concepts. That helps in real life implementation decisions of the technology. Many Thanks for wonderful videos!
@Gringo0517
@Gringo0517 4 жыл бұрын
Love the conversational tone. Great video!
@pragmaticsoftwareengineer7965
@pragmaticsoftwareengineer7965 4 жыл бұрын
excellent stuff mate. so glad I stumbled upon your channel.
@marcosvalderrey5063
@marcosvalderrey5063 Жыл бұрын
Not every day I find great content that is also as engaging and entertaining as yours. Amazing job, Hussein!
@tech3425
@tech3425 Жыл бұрын
I was on another channel watching some web sockets stuff. It's amazing how simple and easy you make stuff sound.
@MrDeeb00
@MrDeeb00 7 ай бұрын
The most passionate instructor I have ever seen. Thank you for this awesome video!
@Akonitx
@Akonitx Жыл бұрын
Bro, your videos with so passion and emotions is really something unbelievable comparing to other plain content in inet. Thanks for your existing!
@shahinbayat
@shahinbayat 4 жыл бұрын
That was an amazing video, I didn't imagine to understand websockets this much comprehensive and with so much fun! keep going mate 👍
@hnasr
@hnasr 4 жыл бұрын
Appreciate you Sir! Thanks 😊 glad you enjoyed the content!
@shahinbayat
@shahinbayat 4 жыл бұрын
@@hnasr I can't stop enjoying the content you have created with such a great energy and giving them for free! That's amazing! I am suggesting your channel to everyone who is interested to learn about network with a simple language! 🙏
@sajithtm4864
@sajithtm4864 2 жыл бұрын
You're such an amazing guy who brings out toughest concepts too simple. Keep doing Bro..👌
@GoldenBeholden
@GoldenBeholden 3 жыл бұрын
I love these very bare-bones tutorials; after all, once you understand the essence of an API, using it to build an application is just a matter of applying whatever programming experience you may already have.
@hnasr
@hnasr 3 жыл бұрын
👍👍
@gnack420
@gnack420 3 жыл бұрын
I gotta say, I love the way you present. It's very casual while still including a lot of information. Great video!
@hnasr
@hnasr 3 жыл бұрын
Nick Coad thanks! Glad you enjoy the content 😊
@annyni6640
@annyni6640 2 жыл бұрын
Love your videos! Have never found anyone else who can teach better
@molangdogma796
@molangdogma796 4 жыл бұрын
I HAVE NEVER KNOWN A GUY AS INTELLIGENT AT EXPLAINING STUFF LIKE Hussein Nasser, MUCH THANKS TO YOU SIR.
@hnasr
@hnasr 4 жыл бұрын
Molang dogma Thank you for watching you humbled me ❤️
@sumedh1771
@sumedh1771 2 жыл бұрын
This is so awesome
@connordelaney2536
@connordelaney2536 2 жыл бұрын
Thank you for taking the time to make this. :)
@gussipp3
@gussipp3 Жыл бұрын
if my career somehow took off it would be mostly because of you man, keep up the great content
@shubhamkala5514
@shubhamkala5514 4 жыл бұрын
for me it's really difficult to watch such a long videos but your way of explaining things is so good that no one can resist it.Do make a video on EventSource.
@hnasr
@hnasr 4 жыл бұрын
Thanks ! I really appreciate your feedback. It is hard to explain complex topic in short video that is why my lectures are long. i try to include time codes of table of contents.. EventSource is on the list! 👍 Thanks!
@tech3425
@tech3425 Жыл бұрын
I love how you always show the tech in the browser(the webRTC video also comes to mind), making it seem so simple that you can type it out in the console. No need for so much tooling. This is literally the only channel I've seen that does it like this.
@hnasr
@hnasr Жыл бұрын
i find it easier for simple things plus everyone has a browser and can quickly do it. not to say editors are not useful of course.
@tech3425
@tech3425 Жыл бұрын
@@hnasr knowingly or not, it greatly reduces the cognitive overhead for viewers when learning a new tech
@TheMathematicalMan
@TheMathematicalMan 2 жыл бұрын
Thanks for the step-by-step guide!
@chintukarthi1781
@chintukarthi1781 2 жыл бұрын
thank you so much for the explanation. Really appreciate all your effort in making this video.
@newtonsarr1234
@newtonsarr1234 3 жыл бұрын
Your tutorials are just amazing. I love it.
@youee1234
@youee1234 4 жыл бұрын
Everything you publish is so pro! thanks for making our lives easier to grasp!
@hnasr
@hnasr 4 жыл бұрын
Thanks 😊 enjoy the content and let me know what you want to see next! Cheers and love
@metinagaoglu4332
@metinagaoglu4332 3 жыл бұрын
Simple and very understandable.Thank you from Turkey, Hussein. I'm gonna watch your all videos.
@hnasr
@hnasr 3 жыл бұрын
Thank you Metin!!
@naimurhasanrwd
@naimurhasanrwd 2 жыл бұрын
Clicked the video, and this guy started explaining with the topic right from 0.00000 seconds! No channel intro, no personal intro.
@akashmocha4846
@akashmocha4846 3 жыл бұрын
Never felt learning was this "ENTERTAINING" before. More power to you❤️
@hnasr
@hnasr 3 жыл бұрын
❤️❤️❤️
@thanasisathanasi4965
@thanasisathanasi4965 4 жыл бұрын
This definitely gets a like and saved in my favorite videos. Best tutorial on the subject !!!!
@hnasr
@hnasr 4 жыл бұрын
Thanks!! Enjoy the content ☺️☺️
@moneeshkumar1838
@moneeshkumar1838 Жыл бұрын
Great Explanation Subscribed Keep posting
@sailendrapavan3475
@sailendrapavan3475 Жыл бұрын
I think Its better to search any topic in this channel first rather than wasting time in searching docs !!! Thanks Hussein Nasser 🤟
@fuckthesystem4444
@fuckthesystem4444 3 жыл бұрын
Dude, ¡your content is AMAZING!
@coolvjh
@coolvjh 3 жыл бұрын
Love your content. Keep them coming!
@SachinKumar-js8yd
@SachinKumar-js8yd 3 жыл бұрын
Liked, subscribed. Your content is GOLD.
@ajayraja1998
@ajayraja1998 4 жыл бұрын
the only video which explains very well thanks a lot brother
@voxhominem
@voxhominem 3 жыл бұрын
damn that was actually helpful. I swear I've read 4 tutorials before now that couldn't have been harder to understand if they'd tried. you earned yourself a new subscriber my dude
@hnasr
@hnasr 3 жыл бұрын
Thank you Vox for watching and I am glad I earned your trust. Hopefully I deliver the content you enjoy cheers! thanks ..
@shrestha0144
@shrestha0144 2 жыл бұрын
I just love your teaching style
@edwinroman30
@edwinroman30 2 жыл бұрын
New subscriber. Awesome content and great explanation. I'm speechless many thanks for all and the recommended sources.
@seems-legit
@seems-legit 2 жыл бұрын
You beautiful man, All other tutorials ive found have tried to make websockets seem like this dark mystic old gods tech that you haver to handle handshakes manually and send control frames. you got a subscriber
@azazel-oss
@azazel-oss Жыл бұрын
Love your content man, so full of information everytime I re-watch any of your long videos I always learn something new. Appreciate your work
@AhmedAli-go7wx
@AhmedAli-go7wx 3 жыл бұрын
thanks, Nasser for this great content ...
@kaloyangeorgiev6824
@kaloyangeorgiev6824 3 ай бұрын
Thank you very much, amazing explanation!
@Mfbzai
@Mfbzai 2 жыл бұрын
Apple need this guy, the speaking way is awesome.
@mhh263
@mhh263 3 жыл бұрын
Everyone thiinks Client-Server model is dead, but hey Hussein comes to rescue. Great stuff man 👍
@zolika154
@zolika154 3 жыл бұрын
literally had me laughing out loud like 3 times
@JoaoRodrigues-yw3bh
@JoaoRodrigues-yw3bh 6 ай бұрын
Amazing and timeless!!
@alitariq7726
@alitariq7726 7 ай бұрын
Love your work. 👍👍👍
@raffayhussain6717
@raffayhussain6717 2 жыл бұрын
The great John Danaher says learning should be playful. When I see you, it reminds me of him.
@briandines
@briandines 2 жыл бұрын
Excellent tutorial. You're funny which made this a little bit easier.
@coutinhotiago
@coutinhotiago 3 жыл бұрын
Concerning the 2 TCP connections necessary to have redis pub/sub + req/rep: I believe that since redis RESP3 protocol (redis >=6) it possible to share both in the same TCP connection. BTW, it would be great to see you do a video on redis 6. Stay awesome 😎
@massimoaristide8879
@massimoaristide8879 3 жыл бұрын
Really easy and entertaining introduction.
@jeppechristensen5707
@jeppechristensen5707 2 жыл бұрын
Thanks alot. You made me reconsider the EventSource API 🙂
@jitpackjoyride
@jitpackjoyride 3 жыл бұрын
This is such great content, thank you.
@iyxan2340
@iyxan2340 2 жыл бұрын
I just love this channel!
@AvnishKumar-zf9km
@AvnishKumar-zf9km 3 жыл бұрын
great explained everything. thank a lot bro.
@stevemcguigan8359
@stevemcguigan8359 2 жыл бұрын
Been waiting for an ah-ha moment on this for a while and this was it. Subbed.
@sourabhkumar6194
@sourabhkumar6194 2 жыл бұрын
Your tutorial really helped me, thanks
@Beny123
@Beny123 2 жыл бұрын
Brilliant job! thanks
@taulantus
@taulantus 4 жыл бұрын
i usually don't comment, but i have to give you the props for this amazing video. good job
@hnasr
@hnasr 4 жыл бұрын
Thanks for taking the time to comment! Appreciate it , glad I could help. have a beautiful day. 😊
@kjahirhussain
@kjahirhussain 2 жыл бұрын
Love the explanation!
@okage_
@okage_ 7 ай бұрын
pretty good video, i learnt alot! thank you
@ayanSaha13291
@ayanSaha13291 8 ай бұрын
Thanks for the video. It helps.
@Pablo-np2ny
@Pablo-np2ny 3 жыл бұрын
fantastic explanation, thanks!
@rshaikh05
@rshaikh05 3 жыл бұрын
jazakAllahu khair. keep up the good work.
@richardmaduka4747
@richardmaduka4747 4 жыл бұрын
I'm glad I found your channel, you are great at explaining concepts.
@hnasr
@hnasr 4 жыл бұрын
Thank you! I am glad too that the content is useful 🙏😊
@ishdx9374
@ishdx9374 4 жыл бұрын
Thanks for this video, I found it really easy interesting, since I'm working on a web game right now.
@hnasr
@hnasr 4 жыл бұрын
Amazing! Keep us up to date with the progress of your game. Cheers!
@tech3425
@tech3425 Жыл бұрын
Dude your accent is perfect. Fuck everybody making fun of it. I literally enjoy the way you pronounce stuff differently
@rodeschorpioen
@rodeschorpioen 4 жыл бұрын
Cool and comprehensive video. thx and keep up the good work!
@hnasr
@hnasr 4 жыл бұрын
Thank you Wouter! 🙏
@reemachourey9462
@reemachourey9462 3 жыл бұрын
Came here from your Spotify Podcast! Happy to find awesome content.
@hnasr
@hnasr 3 жыл бұрын
Thanks Reema!!! Welcome to the channel. Enjoy the content 😊😊
@paulstaley4245
@paulstaley4245 4 жыл бұрын
I'm 11 minutes into this video and I love how professional this video is. Well done with the structuring! I can't believe this only has 4k views.
@hnasr
@hnasr 4 жыл бұрын
Thanks Paul! I appreciate your comment glad the content is of high value to you. Let me know what software engineering content would you like me to make. Cheers
@webrevolution.
@webrevolution. Жыл бұрын
19:15 Right there man. Right there you got my subscription. LOL.
@kidjr.9520
@kidjr.9520 8 ай бұрын
Very clear and the illustrations made it easier to visualize! Very Efficient video on web sockets!
@lonewolf2547
@lonewolf2547 3 жыл бұрын
A M A Z I N G.....!!!!! awesome explanation dude
@marianbieda
@marianbieda 9 ай бұрын
Dziękujemy.
@dennislarsen5744
@dennislarsen5744 3 жыл бұрын
Thanks for this awesome video.
@shaukat9823
@shaukat9823 3 жыл бұрын
Amazing stuff Hussein , Thanks a ton
@hnasr
@hnasr 3 жыл бұрын
Thank you dear
@SohailKhan-cb9ls
@SohailKhan-cb9ls 3 жыл бұрын
Thank you brother, you just solved a system design problem for me. You have a great and unique teaching technique, don't change it. I would really appreciate if you also cover cloud system designs. Thanks again 👍
@hnasr
@hnasr 3 жыл бұрын
🙏🙏🙏
@dhanalakshmi_narala
@dhanalakshmi_narala 3 жыл бұрын
Thank you.. Great explanation
@madanmohanpachouly6135
@madanmohanpachouly6135 2 жыл бұрын
Real cool explanation.
@andrescastillo2863
@andrescastillo2863 4 жыл бұрын
thank you for defining the levels of cool Hussein!
@hnasr
@hnasr 4 жыл бұрын
Andres Castillo 😂 your welcome! Someone made it to the end I see
@andrescastillo2863
@andrescastillo2863 4 жыл бұрын
@@hnasr yeah but i listened interupted between commute to work and home......I need to sit down and listen to this and watch this soon as well.
@ebukaume
@ebukaume 9 ай бұрын
Another nice one from you, thanks 🙌. How does websocket compare to the protocols used by services like Redis or postgreSQL?
@yadude101
@yadude101 2 жыл бұрын
This is a great video. I like how you explain stuff 😀. It would be great if you could build a live web streaming build, a one to many webrtc, like twitch or youtube live streaming... thnx👍🏻
@HM_Milan
@HM_Milan 3 жыл бұрын
What a amazing video, awesome how you dilever
@dabbopabblo
@dabbopabblo Жыл бұрын
Everything I make is with websockets. Maybe that's for the better or maybe its for the worst. I just loooove the bidirectional communication soo much, it allows me to monitor absolutely every little thing about the clients connected to my website in real time and provide them with live updates for the pages they are on
@kefahissa
@kefahissa 3 жыл бұрын
I love your comprehensive coverage and depth. Keep it up! 💚
@hnasr
@hnasr 3 жыл бұрын
So glad! thanks Kefah
@Twerqt
@Twerqt 4 жыл бұрын
Wonderful explanation. Can you explain the etymology of the term "socket" ... it is widely used in various places, from OS inter-process communication to TCP sockets and stuff ...
@section9999
@section9999 3 жыл бұрын
Your accent if fine my dude. We can totally understand what you're saying perfectly. Case in point, I also speak Spanish but no way in hell can I explain backend engineering topics of this level of technical detail in Spanish (or English) as clearly as you can in English. What matters more is the quality of your content, and you sir have some A grade quality content! After watching this I would subscribe, but problem is, I'm already subscribed!
@hnasr
@hnasr 3 жыл бұрын
Thank you Norberto 😍😍
@pallanti_techtalk
@pallanti_techtalk 2 жыл бұрын
Great explanation
@jervex-e3514
@jervex-e3514 Жыл бұрын
such as a treasure thanks!!
@vishg28
@vishg28 3 жыл бұрын
Great explanation. thanks. BTW, it could also help if there is some clarification on difference between Winsock API (WSA) and WebSockets. Like are these two parallel protocols or one can be built on top of another (like Websockets built using WSA) ?
@exoticcoder5365
@exoticcoder5365 2 жыл бұрын
Great one !
@ashishmaikhuri3950
@ashishmaikhuri3950 2 жыл бұрын
Nice work Hussain. I am finally able to understand websocket
@hnasr
@hnasr 2 жыл бұрын
🙏
@bardhan.abhirup
@bardhan.abhirup 3 жыл бұрын
Hey Hussein, thanks a ton for the videos. Just discovered them. The content seems great! I hope you don't mind me saying that you volume levels need adjusting. At times it sounds like you're whispering into the mic and it's not audible, other times it's super loud. If you could somehow normalize that, it'd be great. Thanks!
@hnasr
@hnasr 3 жыл бұрын
Thank you so much! I am working on my audio and making better I think it got better on my new videos.
@sohamnavadiya992
@sohamnavadiya992 2 жыл бұрын
Learn a lot from your videos. Thank you for sharing. I have one request please upload one video on long pooling.
@hnasr
@hnasr 2 жыл бұрын
I Made a video a while back Long Polling and how it differs from Push, Poll and SSE - The Backend Engineering Show kzbin.info/www/bejne/gGHSnKWXfquDgJI
@thomastaylor1799
@thomastaylor1799 2 жыл бұрын
#1 Your a smart dude. #2 You are a great teacher. #3 Don't apologize for your accent, it is cool!
@hamidreza2480
@hamidreza2480 6 ай бұрын
thanks it was very teachingful💯💯💯
@FullRGB
@FullRGB 3 жыл бұрын
Awesome video!
@CoentraDZ
@CoentraDZ 3 жыл бұрын
Your content is priceless ❤️
@hnasr
@hnasr 3 жыл бұрын
❤️❤️ thank you!!
@uchennanwanyanwu2777
@uchennanwanyanwu2777 4 жыл бұрын
7:14 ...it's the wild west. very funny explanation. cool
WebRTC Crash Course
1:10:06
Hussein Nasser
Рет қаралды 215 М.
SSL/TLS Termination, TLS Forward Proxy Pros and Cons
16:56
Hussein Nasser
Рет қаралды 30 М.
Don’t take steroids ! 🙏🙏
00:16
Tibo InShape
Рет қаралды 28 МЛН
😱СНЯЛ СУПЕР КОТА НА КАМЕРУ⁉
00:37
OMG DEN
Рет қаралды 1,8 МЛН
Building a Multi-player Game with WebSockets
1:46:07
Hussein Nasser
Рет қаралды 120 М.
Don't Use Websockets (Until You Try This…)
6:46
Code With Ryan
Рет қаралды 277 М.
What is WebSocket? Why is it used & how is it different from HTTP?
33:23
How HTTP/2 Works, Performance, Pros & Cons and More
22:45
Hussein Nasser
Рет қаралды 101 М.
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 316 М.
Building a Chat App - Intro to WebSockets
19:13
Dave Gray
Рет қаралды 37 М.
Learn HTML5 and CSS3 For Beginners - Crash Course
3:54:03
developedbyed
Рет қаралды 2,8 МЛН
Теперь это его телефон
0:21
Хорошие Новости
Рет қаралды 1,1 МЛН
Android top🔥
0:12
ARGEN
Рет қаралды 1,4 МЛН
Which Phone Unlock Code Will You Choose? 🤔️
0:14
Game9bit
Рет қаралды 7 МЛН
Распаковка айфона в воде😱 #shorts
0:25
Mevaza
Рет қаралды 1,2 МЛН