websocket corrupted by chunked encoding
Trying this nodejs demo on apache and mod_passenger. But socket.io is only falling back to polling as the websocket gets corrupted by apache sending the upgrade response using chunked encoding:
Following is the response packet that indicates switching to websocket:
HTTP/1.1 101 Switching Protocols
Date: Thu, 10 Apr 2014 15:21:28 GMT
Server: Apache/2.2.15 (CentOS)
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: S7wgnmtVSahQDCifkYwFlQajWcI=
X-Powered-By: Phusion Passenger 4.0.41
Status: 101 Switching Protocols
Transfer-Encoding: chunked
Content-Type: text/plain; charset=UTF-8
5
..1::
The problem is that right after the http headers the server (nodejs) sends actual websocket frame but apache encodes it using chunked encoding (prepends it with chunk length - the number 5 in my example). Since the first byte of websocket frame is supposed to be frame opcode the chunk length is taken by browser (tested with Chrome) as this opcode and whole websocket is corrupted.
What am I doing wrong?
Thanks, Antony.
You are doing nothing wrong. Probably a bug in Phusion Passenger. I'll have this resolved with high priority for 4.0.45.