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

Опубликовано: 23 Август 2019
на канале: Hussein Nasser
290,188
7.9k

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
https://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:

https://developer.mozilla.org/en-US/d...

https://www.ably.io/concepts/websockets

  / ljssosnw6y  

https://blog.stanko.io/do-you-really-...



Cards
HTTP Crash Course    • Hyper Text Transfer Protocol Crash Co...  
TLS    • Transport Layer Security, TLS 1.2 and...  
What is a Web Servers    • What are web servers and how do they ...  
Layer 4 vs Layer 7 Load Balancing    • Load balancing in Layer 4 vs Layer 7 ...  





Support my work on PayPal
https://bit.ly/33ENps4

Become a Member on YouTube
   / @hnasr  

🧑‍🏫 Courses I Teach
https://husseinnasser.com/courses

🏭 Backend Engineering Videos in Order
https://backend.husseinnasser.com

💾 Database Engineering Videos
   • Database Engineering  

🎙️Listen to the Backend Engineering Podcast
https://husseinnasser.com/podcast

Gears and tools used on the Channel (affiliates)

🖼️ Slides and Thumbnail Design
Canva
https://partner.canva.com/c/2766475/6...

🎙️ Mic Gear
Shure SM7B Cardioid Dynamic Microphone
https://amzn.to/3o1NiBi

Cloudlifter
https://amzn.to/2RAeyLo

XLR cables
https://amzn.to/3tvMJRu

Focusrite Audio Interface
https://amzn.to/3f2vjGY


📷 Camera Gear
Canon M50 Mark II
https://amzn.to/3o2ed0c

Micro HDMI to HDMI 
https://amzn.to/3uwCxK3

Video capture card
https://amzn.to/3f34pyD

AC Wall for constant power
https://amzn.to/3eueoxP


Stay Awesome,
Hussein


Смотрите видео WebSockets Crash Course - Handshake, Use-cases, Pros & Cons and more онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Hussein Nasser 23 Август 2019, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 290,18 раз и оно понравилось 7.9 тысяч людям.