websocket - IE10 握手后关闭连接

标签 websocket internet-explorer-10

我确实在 libevent 中实现了一个 websocket 服务器,虽然我对 Chrome 或 Firefox 没有任何问题,但使用 IE10 我什至无法建立连接。

这里握手:

IE10 Request:
GET /echo HTTP/1.1
Origin: 95.115.195.4
Sec-WebSocket-Key: rgPWUlUtk+h3CPWqk99OtA==
Connection: Upgrade
Upgrade: Websocket
Sec-WebSocket-Version: 8
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)
Host: 95.115.195.4:5555
Cache-Control: no-cache

Server Response:
HTTP/1.1 101 Switching Protocols
Upgrade: Websocket
Connection: Upgrade
Sec-WebSocket-Accept: jGmgQ/jOvew8MU9o3bbqPG9PHlY=
Sec-WebSocket-Protocol: chat

IE10 调试器说:
SCRIPT12152:WebSocket 错误:HTTP 响应不正确。状态码 101

有人知道我在做什么错吗?

谢谢

最佳答案

客户端未发送子协议(protocol)列表,但您的服务器已将“聊天”作为子协议(protocol)值发回。根据IETF 6455 WebSocket spec的第19页| (第 4.1 节客户要求结束):

6.  If the response includes a |Sec-WebSocket-Protocol| header field
   and this header field indicates the use of a subprotocol that was
   not present in the client's handshake (the server has indicated a
   subprotocol not requested by the client), the client MUST _Fail
   the WebSocket Connection_.
如果客户端向服务器发送了“Sec-WebSocket-Protocol: SUBPROTOCOL,...” header ,则服务器应仅将“Sec-WebSocket-Protocol: SUBPROTOCOL” header 发送回客户端。请注意,客户端可以发送子协议(protocol)列表,如果发送,服务器必须从列表中选择一个进行响应。
Firefox 和 Chrome 可能过于宽松,没有遵守当前版本的规范。

关于websocket - IE10 握手后关闭连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9444693/

相关文章:

css - 即使滚动 ="yes"和溢出 : scroll,IE 10 也不会在 iframe 上显示滚动条

javascript - 在 JavaScript 中从套接字获取消息时出错

ssl - Jetty ssl 端口没有为安全的 JSR-356 websockets 打开

eclipse - WebSocket- "Error during WebSocket handshake: Unexpected response code: 404"将外部 jar 添加到项目时

jquery - IE10 - 需要将 CSS 光标更改为 "pointer"在 contenteditable <div> 中 <span> 上的鼠标输入

html - 浏览器滚动在 Internet Explorer 10 中不起作用

Apache2 无法设置 header "Connection"和 "Upgrade"

websocket - Tornado 的 websocket 实现如何查找和关闭僵尸 websockets?

javascript - 检查 IE 10

javascript - 我怎样才能在 IE 中获取 event.path?