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. Autofac官方文档翻译--二、解析服务--1解析参数传递

    Autofac 传递解析参数 注册组件公开相应的服务之后,你可以从container构造器和子lifetime scopes 中解析服务.使用Resolve()方法来实现: var builder = ...

  2. Spring Data Cache

    Spring Data Cache注解使用 方法是一个对象,使用对象中的属性,如ID,作为cache key RedisConnection超时设置 参考 SpringBoot使用Redis缓存

  3. 使用@Cacheable注解时,Redis连不上,直接调用方法内部的解决方案

    最近redis 域名一致解析错误,导致业务多了很多异常.那么如何在这种情况下直接访问数据库,而不是报错呢 1. 解决方案 其实很简单,在配置 redis 时,只需要多一项配置,继承 CachingCo ...

  4. VS Code 自动化连接非固定IP地址EC2实例的解决方案

    问题描述 大家可能和我一样,平时在AWS上启动一台安装有Linux EC2实例作为远程开发机. (注:这里的EC2实例是配置用私钥进行登录的) 通常,你可以选择申请一个Elastic IP绑定到这台开 ...

  5. linux零基础之--使用putty配置

    PuTTY是一个Telnet.SSH.rlogin.纯TCP以及串行接口连接软件.随着Linux在服务器端应用的普及,Linux系统管理越来越依赖于远程.在各种远程登录工具中,Putty是出色的工具之 ...

  6. 为什么import React from 'react',React首字母必须大写?

    很奇怪的是,明明没有用到 React,但是我不得不 import React.这是为什么? import React from 'react'; export default function (pr ...

  7. 读《白帽子讲web安全》 ——笔记

    第二章 浏览器安全 什么是同源策略? 同源策略,它是由Netscape提出的一个著名的安全策略. 现在所有支持JavaScript 的浏览器都会dao使用这个策略. 所谓同源是指,域名,协议,端口相同 ...

  8. 一个轻量级的.Net Core微服务快速开发的轮子

    前言     Adnc是一个轻量级的.Net Core微服务快速开发框架,同时也可以应用于单体架构系统的开发.框架基于JWT认证授权.集成了一系列微服务配套组件,代码简洁.易上手.学习成本低.开箱即用 ...

  9. 如何限制电脑访问网址—使用Host限制访问网址

    如何限制电脑访问网址-使用Host限制访问网址 1. 打开C:\Windows\System32\drivers\etc 2. 打开hosts 3. 修改host内容,如下示例 127.0.0.1  ...

  10. ORA-39700: database must be opened with UPGRADE option【转】

    1. 错误 数据库升级后(从11.2.0.1升级到11.2.0.4)启动报错 SQL> startup ORACLE instance started.   Total System Globa ...