2012-02-25 107 views
4

我在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

任何人都知道我在做什麼錯?

感謝

回答

5

的客戶端沒有發送的子協議的列表,但您的服務器發回「聊天」作爲子協議的價值。據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

相關問題