Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebSocket Traffic Encoding (GZip)

StackOverflow uses the GZip encoding on all of their pages; the same seems to be true for their websocket traffic since it seems completely obfuscated.

enter image description here

How/What would they use to achieve this; rather what would I need to do to achieve the same since my websocket server is hosted on its own separate server without IIS etc?

Worth noting too that the http compression is not set on their websocket connection request either.


Full log screenshot: http://i44.tinypic.com/19s4yr.jpg

like image 441
cillierscharl Avatar asked Apr 08 '12 09:04

cillierscharl


2 Answers

According to RFC6455, WebSocket payload from client to server MUST be masked, server to client MUST NOT be masked. The masking is done by XORring payload with 32 Bit mask .. the value you see in your log.

There is a WS extension in the cooking that provides frame-based compression (deflate). This has nothing to do with masking. Payload with per-frame-compression active compresses payload, and then masks payload (client to server).

like image 137
oberstet Avatar answered Sep 22 '22 14:09

oberstet


I don't think there is any gzipping here. It looks like fiddler has started adding support for websockets but its still a work in progress.

The log shows a connection
...then a first message of 12 bytes (461287-inbox. The initial bytes 81 8C show a new, complete, text frame with 4 byte mask and 12 bytes of data. Fiddler correctly decodes this.)
...then a second message of 19 bytes (the bytes 81 93 - 19 bytes into the stream - show a new, complete, text frame with 4 byte mask and 19 bytes of data)
...then a third message of 19 bytes (the later bytes 81 93 - approx 44 bytes into the stream - show a new, complete, text frame with 4 byte mask and 19 bytes of data)

like image 20
simonc Avatar answered Sep 22 '22 14:09

simonc