Question

i did implement a websocket server in libevent and while i dont have any problems with Chrome or Firefox, with IE10 i am not even able to establish a connection.

Here the Handshakes:

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

The IE10 debugger says: SCRIPT12152: WebSocket Error: Incorrect HTTP response. Status code 101

Anyone knows what i am doing wrong?

Thanks

Was it helpful?

Solution

The client did not send a list of sub-protocols, but your server has sent back "chat" as the sub-protocol value. According to page 19 of IETF 6455 WebSocket spec (end of section 4.1 Client Requirements):

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_.

The server should only send the "Sec-WebSocket-Protocol: SUBPROTOCOL" header back to the client if the client sent a "Sec-WebSocket-Protocol: SUBPROTOCOL,..." header to the server. Note that the client can send a list of sub-protocols, and if it does, the server must select one from the list to respond with.

It's possible that Firefox and Chrome are being too lenient and not adhering to the current version of the spec.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top