新的 HTTP/2 协议(protocol)具有一些有前途的特性。他们中有一些:
A "stream" is an independent, bidirectional sequence of frames exchanged between the client and server within an HTTP/2 connection.
此处解释了 HTTP/2 背后的动机 HTTP/2 FAQ :
HTTP/1.1 has served the Web well for more than fifteen years, but its age is starting to show.
和
The goal of the Working Group is that typical uses of HTTP/1.x can use HTTP/2 and see some benefit.
所以 HTTP/2 很好,可以取代 HTTP/1.x。不幸的是,HTTP/2 does not support WebSockets .在这个问题Does HTTP/2 make websockets obsolete?明确表明 HTTP/2 服务器推送不是替代方案,Server-Sent Events 也不是。 .
现在问题来了:如果我们想要通过 HTTP/2 实现 WebSockts 功能,我们应该使用什么?
最佳答案
好吧,你的时机相当合适!
互联网标准草案的新版本刚刚发布:
Bootstrapping WebSockets with HTTP/2
此处的附加信息:
https://github.com/mcmanus/draft-h2ws/blob/master/README.md
您可以在此处关注其中的讨论:
https://lists.w3.org/Archives/Public/ietf-http-wg/2017OctDec/0032.html
在这被批准,然后由浏览器和服务器实现之前,我会说 Daniel Haxx’s post that you included in your question代表了当前状态的一个很好的总结。
关于websocket - HTTP/2 世界中的 WebSockets 替代方案是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46753263/