4

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

誰が私が間違っているのか知っていますか?

ありがとう

4

1 に答える 1

5

クライアントはサブプロトコルのリストを送信しませんでしたが、サーバーはサブプロトコル値として「chat」を返信しました。IETF 6455 WebSocket 仕様の 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,...」ヘッダーをサーバーに送信した場合、サーバーは「Sec-WebSocket-Protocol: SUBPROTOCOL」ヘッダーのみをクライアントに送信する必要があります。クライアントはサブプロトコルのリストを送信できることに注意してください。送信する場合、サーバーはリストから 1 つを選択して応答する必要があります。

Firefox と Chrome が寛大すぎて、現在のバージョンの仕様に準拠していない可能性があります。

于 2012-02-25T21:12:17.457 に答える