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. springcloud根据日期区间查询同时其他字段模糊查询

    /** * 分页查询完工送检单 * @param entity * @param query * @return */ @GetMapping("getQcProInsAppOverList ...

  2. 有两张表;使用SQL查询,查询所有的客户订单日期最新的前五条订单记录。

    客户信息表(c CUSTOM)有以下字段:id.name.mobile 客户订单表(C_ORDER)有以下字段:id.custom_id.commodity.count.order _date Sel ...

  3. java左移右移运算符详解

    在阅读源码的过程中,经常会看到这些符号<< ,>>,>>>,这些符号在Java中叫移位运算符,在写代码的过程中,虽然我们基本上不会去写这些符号,但需要明白这些 ...

  4. hive on spark:return code 30041 Failed to create Spark client for Spark session原因分析及解决方案探寻

    最近在Hive中使用Spark引擎进行执行时(set hive.execution.engine=spark),经常遇到return code 30041的报错,为了深入探究其原因,阅读了官方issu ...

  5. Element UI组件说明

    -<el-card>-查询及展示列表页面-[v-show]属性控制显示隐藏-<el-card class="box-card" >-多标签页面-<el ...

  6. 2.1 关系型数据的收集--Sqoop

    Sqoop应用场景: 1.数据迁移,将关系型数据库中的数据导入Hadoop存储系统 2.可视化分析结果,将Hadoop处理之后产生的结果导入关系型数据库,以便进行可视化展示 3.数据增量导入:减少ha ...

  7. Elastisearch在kibana下批量处理(mget和bulk)

    一.批量查询 有点:能够大大减少网络的请求次数,减少网络开销 1.自定义设置index.type以及document id,进行查询 GET /_mget { "docs":[ { ...

  8. PPT 转 word

    可以wps  直接转 打开wps   在页面里直接点击右键  可以导出wps

  9. MyBatis中id回填的两种方式

    在一种场景下需要刚刚插入数据的ID,如果数据少可以先看数据库,记下ID,但数据很多,假设一万个用户并发,每个用户都插入自己的ID,就很难记下来. 下面给定一个场景: 1 User user = new ...

  10. vue 深度作用选择器

    使用 scoped 后,父组件的样式将不会渗透到子组件中 如果想在使用scoped,不污染全局的情况下,依然可以修改子组件样式,可以使用深度作用选择器 .tree{ width: 100%; floa ...