IE10在握手后关闭连接

问题描述:

我在libevent中实现了一个websocket服务器,虽然我没有任何Chrome或Firefox的问题,但IE10我甚至无法建立连接。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

任何人都知道我在做什么错?

感谢

的客户端没有发送的子协议的列表,但您的服务器发回“聊天”作为子协议的价值。据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协议:子协议”头,返回给客户端,如果客户端发送一个“仲 - WebSocket协议:SUBPROTOCOL,...“头到服务器。请注意,客户端可以发送子协议列表,如果有,则服务器必须从列表中选择一个来响应。

Firefox和Chrome可能过于宽松,并且不遵守当前版本的规范。

+1

解决了!谢谢! – 2012-02-25 23:52:35