WebSockets速成課程



WebSockets技術是用於雙向客戶端和伺服器之間通過Web進行通信的雙向全雙工協議。它已於2011年標準化,並與HTTP完全兼容。該協議支持實時應用,例如聊天,通知,實時供稿,多人遊戲和其他用例。

在本視頻中,我們將解釋什麼是WebSocket以及其發明的原因。然後,我們將使用WebSockets構建伺服器和客戶端。我們還將討論WebSockets的優缺點,並討論該技術的一些替代方案

視頻中的WebSockets源代碼
https://github.com/hnasr/javascript_playground/tree/master/websocket-demo

HTTP
  *談論請求-響應顯示幻燈片。客戶一直在發起請求。想像一下構建一個聊天應用程序嗎?

Web套接字
-幻燈片顯示雙向全雙工標準網頁

WebSockets如何工作?
-WebSockets握手
-初始請求始終是HTTP,眾所周知,HTTP會創建一個tcp連接,然後該請求進行http升級,告訴伺服器將其用作雙向。
-一旦完成切換到二進位協議。
-Ws:// wss://協議

WebSocket用例
-聊天
-實時供稿
-多人遊戲
-進度欄/日誌記錄/上傳。

-WebSockets示例(伺服器/客戶端)
-WebServer的優缺點

優點
1.全雙工,無需持續輪詢
2.與HTTP兼容,因此代理知道如何處理
3.防火牆不會阻止它,它不會使用特殊埠
缺點
1.代理很棘手,許多代理和透明代理尚不支持
2.第7層負載平衡很棘手,負載平衡器超時。
3.實現起來比較複雜(簡單的telnet使用HTTP)
4.對於所有用例都不理想-(微服務)

-是否必須使用Web套接字? ( 備擇方案 )
重要的是要注意,WebSockets並不是唯一基於HTTP實時的解決方案,還有其他實現實時的方法,例如事件源和長時間輪詢。

-使用WebSocket進行負載平衡(獎金)
-第4層
-第7層(隧道)

長輪詢
事件源
Web套接字

 
資料來源:

https://developer.mozilla.org/zh-CN/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

跳轉碼

HTTP 2:00
Web套接字5:40
WebSockets握手8:00
WebSockets用例11:20
14:30 WebSockets示例代碼
36:40 WebSockets的優缺點
42:10您必須使用webSockets嗎?


2:40 HTTP速成班https://www.youtube.com/watch?v=0OrmKCB0UrQ
8:20 TLS https://www.youtube.com/watch?v=AlE5X1NlHgg
9:00什麼是Web伺服器https://www.youtube.com/watch?v=JhpUch6lWMw
39:40第4層與第7層負載平衡https://www.youtube.com/watch?v=aKMLgFVxZYk

Architecture軟體架構視頻

?資料庫工程視頻

?網路工程視頻

?負載平衡和代理視頻

?Postgres視頻

?程式設計影片

?網路安全視頻

?HTTP視頻

?Python視頻

?Javascript視頻

在PayPal上支持我https://bit.ly/33ENps4
成為贊助人https://www.patreon.com/join/hnasr嗎?

保持好狀況!
海珊。

30 comments
  1. 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.

  2. 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

  3. Hussein in your book , you used the command line 『npm init』 to set up a web server. So, what is the difference between 『npm init』 and 『npm init -y』? Thank you.

Comments are closed.