Can't connect to websocket to work in Chrome 19

I have a websocket client / server that works fine with Firefox and Chrome 18. It doesn’t work with the beta version of Chrome 19. I suspect that because of this browser, an extension with a frame extension that my server does not support is now used.

Chrome 19 beta sends this in his handshake: "Sec-WebSocket-Extensions: x-webkit-deflate-frame"

I am returning my server: "Sec-WebSocket-Extensions:"

But either this is not the right way to reject the extension, or something else is wrong that I will not catch. This is the only handshake that differs from what I see coming from working browsers.

Edit: Here is additional information. This is the handshake captured by Wireshark.


Handshake using Firefox 12:

GET / chatserver HTTP / 1.1
Host: (omitted for this entry)
User-Agent: Mozilla / 5.0 (Windows NT 6.1; WOW64; rv: 12.0) Gecko / 20100101 Firefox / 12.0
Accept: text / html, application / xhtml + xml, application / xml; q = 0.9, /; q = 0.8
Accept-Language: en-us, en; q = 0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: save, update
Sec-WebSocket-Version: 13
Origin: (omitted for this post)
Sec-WebSocket-Key: 2TKm4ozUQdNP17Lobt7IBg ==
Pragma: no-cache
Cache-control: no-cache
Update: websocket

HTTP / 1.1 101 Protocol Switching
Update: websocket
Connection: update
Sec-WebSocket-Accept: pSUB3BT9YUUd9n3mOeWY / 1uVqJE =


Handshake using Chrome 18:

GET / chatserver HTTP / 1.1
Update: websocket
Connection: update
Host: (omitted for this entry)
Origin: (omitted for this post)
Sec-WebSocket-Key: zuHLEC8pGvAMadarhCLXFA ==
Sec-WebSocket-Version: 13

HTTP / 1.1 101 Protocol Switching
Update: websocket
Connection: update
Sec-WebSocket-Accept: LMBSq6Bk9Kiv + zAbQlAL899pfzc =


Handshake using Chrome 19:

GET / chatserver HTTP / 1.1
Update: websocket
Connection: update
Host: (omitted for this entry)
Origin: (omitted for this post)
Sec-WebSocket-Key: TbwnVcuUiqGgZn7hxvxzvQ ==
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: x-webkit-deflate-frame

HTTP / 1.1 101 Protocol Switching
Update: websocket
Connection: update
Sec-WebSocket-Accept: D45BJ + Vfydy1Upcs3Hze / nuiaS8 =
Sec-WebSocket-Extensions:


All server responses have \ r \ n end-lines and include additional \ r \ n at the end of the message.

FF12 and Chrome18 work - Chrome19 does not work . In Chrome19, the very next packet after responding to server confirmation is FIN / ACK. The connection is closed.

pi I also tried using a hyphen as the value of Sec-WebSocket-Extensions, but that didn't work either.

+6
source share
2 answers

Found a problem.

Firstly, the empty Sec-WebSocket-Extensions line in the server response generates the " Invalid UTF-8 sequence in header value " error. After deleting this entry, the remaining error was " A server must not mask any frames that it sends to the client. "

In fact, my server implementation (a heavily modified version of PHPWebSocket) by default masks the frames it sends. Changing this default behavior fixed the problem and connecting to websocket now works in Chrome 19.

Adding the PHPWebSocket tag to this question as this is a problem with this project.

+4
source

For Chrome, the "Sec-WebSocket-Protocol" header should be set to both the server and the client. It concerns me.

0
source

Source: https://habr.com/ru/post/914936/


All Articles