The bottom line:
I don't see websocket messages compressed, even though the permessage-deflate headers exist on both request and response.
Some details:
I have a nodejs server, and I use Primus (with engine.io under). I use the 'compression' feature of Primus, in order to support permessage-delate.
After I turn it on, I start seeing permessage-deflate header on responses.
But I don't see the websocket frames themselves being compressed.
I sniff the traffic using charlesproxy, and again - the frames look the same as they were before I turned the 'compression' feature on.
Illustration:
Here's an example request from the websocket handshake:
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8,he;q=0.6,fr;q=0.4
Cache-Control:no-cache
Connection:Upgrade
Cookie:[some cookies]
Host:[our host]
Origin:https://[our host]
Pragma:no-cache
Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits
Sec-WebSocket-Key:6nMxnGd0E8GrDg2s1B4tHQ==
Sec-WebSocket-Version:13
Upgrade:websocket
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
And this is the corresponding response:
Connection:upgrade
Date:Tue, 11 Jul 2017 14:10:18 GMT
Sec-WebSocket-Accept:lLjOXWbLRVIHw2inxrhx0U1ryrM=
Sec-WebSocket-Extensions:permessage-deflate; client_no_context_takeover
Sec-WebSocket-Version:13
Server:nginx
Upgrade:websocket
WebSocket-Server:uWebSockets
These examples are taken from the Chrome dev tools network inspector. I see something similar in the charlesproxy sniffer.
Other reference:
I saw this:
Implementing permessage-deflate in WebSockets
But I couldn't quite find an valid answer there.
So...
What am I missing here? Do I need to implement something more? Do I need to include any library?
Versions:
- node - 4.2.4
- primus - 7.0.2
- chrome: 59.0.3071.115
- FF: 54.0.1
- charles: 4.1.4
Many thanks!