?/100

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

August 23, 2019191930

Description

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_playground/tree/master/websocket-demo 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/docs/Web/API/WebSockets_API/Writing_WebSocket_servers https://www.ably.io/concepts/websockets https://link.medium.com/ljsSOsnW6Y https://blog.stanko.io/do-you-really-need-websockets-343aed40aa9b Cards HTTP Crash Course https://www.youtube.com/watch?v=0OrmKCB0UrQ TLS https://www.youtube.com/watch?v=AlE5X1NlHgg What is a Web Servers https://www.youtube.com/watch?v=JhpUch6lWMw Layer 4 vs Layer 7 Load Balancing https://www.youtube.com/watch?v=aKMLgFVxZYk Support my work on PayPal https://bit.ly/33ENps4 Become a Member on YouTube https://www.youtube.com/channel/UC_ML5xP23TOWKUcc-oAE_Eg/join 🧑‍🏫 Courses I Teach https://husseinnasser.com/courses 🏭 Backend Engineering Videos in Order https://backend.husseinnasser.com 💾 Database Engineering Videos https://www.youtube.com/playlist?list=PLQnljOFTspQXjD0HOzN7P2tgzu7scWpl2 🎙️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/647168/10068 🎙️ 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

Wheatcha