title: lighttpd/mod_websocket mqtt handshake fail (no subproto)
body: <p>I have set up lighttpd with mod_websocket as discussed in Dom Bramley's blog entry (except that I am using a BeagleBone Black with Debian Wheezy instead of an rPi.)</p>
  
  <p><a href="https://www.ibm.com/developerworks/community/blogs/B-Fool/entry/setting_up_an_mqtt_websocket_gateway_for_raspberry_pi?lang=en" rel="nofollow">https://www.ibm.com/developerworks/community/blogs/B-Fool/entry/setting_up_an_mqtt_websocket_gateway_for_raspberry_pi?lang=en</a></p>
  
  <p>[During the lighttpd/mod_websocket build process I was asked if I wanted to patch the server and I said yes.]</p>
  
  <p>I have the mosquito MQTT broker running on the same host and publishing on various topics.</p>
  
  <p>When I try to connect to the broker with a browser client via the web socket, I can see that everything works okay in terms of the http upgrade to websocket and forwarding the connection request to mosquitto.  Mosquitto gets the connection request and accepts it.  However, the response that gets back to the browser does not include the Sec-Websocket-Protocol header echoing the subproto specifier mqttv3.1 that was in the original upgrade request.  The client correctly rejects this answer and the connection is shut down.</p>
  
  <p>The javascript error from mqttws31.js:912 is "Sent non-empty Sec-Websocket-Protocol header but no response is received."  With Wireshark, I can see that this is true; the 101 Switching Protocols response has headers Upgrade, Connection, and Sec-Websocket-Accept, but nothing else.</p>
  
  <p>My mod_websocket config file defines host, port, type, and subproto the same as Dom's example, and I can see from various debug statements that the request gets all the way to Mosquitto correctly.</p>
  
  <p>Can anyone suggest how to get the Websocket-Protocol header to be included in the response?  It must work, Dom wrote a blog post describing how he did it!</p>