https://tools.ietf.org/html/rfc6455#section-4.4

4.4. Supporting Multiple Versions of WebSocket Protocol


   This section provides some guidance on supporting multiple versions
of the WebSocket Protocol in clients and servers. Using the WebSocket version advertisement capability (the
|Sec-WebSocket-Version| header field), a client can initially request
the version of the WebSocket Protocol that it prefers (which doesn't
necessarily have to be the latest supported by the client). If the
server supports the requested version and the handshake message is
otherwise valid, the server will accept that version. If the server
doesn't support the requested version, it MUST respond with a
|Sec-WebSocket-Version| header field (or multiple
|Sec-WebSocket-Version| header fields) containing all versions it is
willing to use. At this point, if the client supports one of the
advertised versions, it can repeat the WebSocket handshake using a
new version value. The following example demonstrates version negotiation described
above: GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
...
Sec-WebSocket-Version: 25 Fette & Melnikov Standards Track [Page 26]

RFC 6455                 The WebSocket Protocol            December 2011

   The response from the server might look as follows:

      HTTP/1.1 400 Bad Request
...
Sec-WebSocket-Version: 13, 8, 7 Note that the last response from the server might also look like: HTTP/1.1 400 Bad Request
...
Sec-WebSocket-Version: 13
Sec-WebSocket-Version: 8, 7 The client now repeats the handshake that conforms to version 13: GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
...
Sec-WebSocket-Version: 13
使用WebSocket版本标记字段(`Sec-WebSocket-Version`header字段),客户端可以在最初请求时选择WebSocket协议的版本号(客户端不必要支持最新的版本)。如果服务端支持请求的版本并且我收到消息是有效的,那么服务端会接受这个版本。如果服务端不支持客户端请求的版本,那么服务端必须返回一个`Sec-WebSocket-Version`header字段(或者多个`Sec-WebSocket-Version`header字段)包含服务端支持的所有版本。在这种情况下,如果客户端支持其中任意一个版本,它可以选择一个新的版本值重新发起握手请求。
 
 

Supporting Multiple Versions of WebSocket Protocol 支持多版本WebSocket协议的更多相关文章

  1. The WebSocket Protocol

      [Docs] [txt|pdf] [draft-ietf-hybi-t...] [Diff1] [Diff2] [Errata] Updated by: 7936 PROPOSED STANDAR ...

  2. Netty对WebSocket的支持(五)

    Netty对WebSocket的支持(五) 一.WebSocket简介 在Http1.0和Http1.1协议中,我们要实现服务端主动的发送消息到网页或者APP上,是比较困难的,尤其是现在IM(即时通信 ...

  3. Supporting Multiple Screens 翻译 支持各种屏幕(上)

    Supporting Multiple Screens 支持各种各样的屏幕尺寸.屏幕密度 Android runs on a variety of devices that offer differe ...

  4. Tomcat和Jetty对WebSocket的支持

    公司项目须要,了解了下眼下几种支持WebSocket的框架.曾经用jWebSocket做过一些项目.相对来说.改jWebSocket的源代码略复杂,也不是一天两天能搞定的. 一调研才发现,如今非常多主 ...

  5. 让ie6 7 8 9支持原生html5 websocket

      让ie6 7 8 9支持原生html5 websocket   从github上的 web-socket-js(socket.io好像也是用这个做的他们的flash替代传输方式)改过来的.不过值得 ...

  6. 前后端通信—webSocket(支持跨域)

    WebSocket 的介绍 WebSocket 是什么 WebSocket 是一种网络通信协议.RFC6455 定义了它的通信标准. WebSocket 是 HTML5 开始提供的一种在单个 TCP ...

  7. PHPFarm - How to run multiple versions of PHP on the same computer

    How to Run Multiple Versions of PHP on One Server 转载:http://www.sitepoint.com/run-multiple-versions- ...

  8. Hive的Metastore contains multiple versions

    hive 客户端报错:Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeExcepti ...

  9. Spark Sql数仓报-Metastore contains multiple versions

    Spark版本为2.1.0,Hadoop版本为2.7.1,元数据存储在mysql中,异常信息如下: Exception in thread "main" java.lang.Run ...

随机推荐

  1. (十三)、向shell脚本中传参

    一.向脚本中传递位置参数 向脚本中传递参数的数目理论上可以无数多,但是只有前9个能被访问,使用shift可以改变此限制 $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 脚本名字 first ...

  2. 关于ajax已经成功了,却报404的错误的问题

    经分析是请求没有返回状态码,这是因为我用的是SpringMVC框架,前后端使用JSON传递数据,因为返回的是对象,而忘记了添加 @ResponseBody 注解,所以 Spring对我的返回值进行了映 ...

  3. 浅入kubernetes(1):Kubernetes 入门基础

    目录 Kubernetes 入门基础 Introduction basic of kubernetes What Is Kubernetes? Components of Kubernetes Kub ...

  4. 单细胞分析实录(1): 认识Cell Hashing

    这是一个新系列 差不多是一年以前,我定导后没多久,接手了读研后的第一个课题.合作方是医院,和我对接的是一名博一的医学生,最开始两边的老师很排斥常规的单细胞文章思路,即各大类细胞分群.注释.描述,所以起 ...

  5. Ubuntu20.04编译ffmpeg

    1.安装编译所需工具,GCC 2.安装yasm nasm yasm和nasm是两个编译器,编译ffmpeg需要用到 安装命令: sudo aptitude install yasm nasm 3.安装 ...

  6. C#中存储过程和DataTable的应用

    存储过程p_OperatorDetails,有四个参数@sDatetime,@eDatetime,@operatorNo,@transdesc.其中@operatorNo和@transdesc为两个可 ...

  7. 三目运算符(C++)

    一.简介 固定格式 ?: 三目运算符:可用于赋值语句 三目运算表达式:<表达式1>?<表达式2>:<表达式3> 注:"?"运算符的含义是: 先求 ...

  8. NOIP初赛篇——03中央处理器CPU

    CPU ​ CPU(中央处理单元)是微机的核心部件,是决定微机性能的关键部件.20世纪70年代微型机的CPU问世,微型计算机的核心部件微处理器从Intel 4004,80286,80386,80486 ...

  9. 认识webservice

    1.为什么需要webservice? 目前还有很多商用程序继续在使用C++.Java.Visual Basic和其他各种各样的语言编写.现在,除了最简单的程序之外,所有的应用程序都需要与运行在其他异构 ...

  10. 【MySQL】DDL数据定义语言的基本用法create、drop和alter(增删改)

    DDL 的基础语法 文章目录 DDL 的基础语法 对数据库进行定义 对数据表进行定义 创建表结构(数据表) 设计工具 修改表结构 小结 参考资料 简单复习一波 SQL必知必会 DDL 的英文全称是 D ...