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吗?
保持好状况!
侯赛因。
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!
7:14 …it's the wild west. very funny explanation. cool
dude, this could've been like 20 minute shorter without your antics.
thank you very much
i usually don't comment, but i have to give you the props for this amazing video. good job
Thanx Hussein
Say with me it's coolish ????? i loved the way you explain i enjoyed along with u thank you so much keep going ???
Hey could you please do a video about EventSource?
Everything you publish is so pro! thanks for making our lives easier to grasp!
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.
could you share your lounch.json file? I'm trying to follow your steps but it's not working
شكرا جزيلا على هذا الشرح
while connecting client and server m getting error on client side connection cannot be established
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.
I always like it when a channel has the perfect balance of comedy and education. Subscribed! Great stuff!
Thanks for this video, I found it really easy interesting, since I'm working on a web game right now.
I personally use this websocket server library: https://www.npmjs.com/package/ws
It doesn't require to create an http server which is pretty nice
who uses 1.0 anyway?
WEBrtc is also trending for a client to client video and audio chat. Will you please make a crash cource about it?
Thanks 🙂
excellent stuff mate. so glad I stumbled upon your channel.
assalamualaikum hussain sir
can you assist me on how to send message to a specific user using websocket
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
THE FIRST 5 MINUTES INTO YOUR VIDEO MADE ME UNDERSTAND OVER 3 YEARS WORTH OF INFORMATION, U ARE A BLESSING Hussein Nasser
I HAVE NEVER KNOWN A GUY AS INTELLIGENT AT EXPLAINING STUFF LIKE Hussein Nasser, MUCH THANKS TO YOU SIR.
thank you for defining the levels of cool Hussein!
Can you make a Video how to make Bots for Online Games using Websockets? ?
Very nice.
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.
Hussein I was wondering maybe if you can share your PPTs with us? I want to print them out and take notes on them ?
YES !!! I claim the first comment