--- websockets.py	2012-10-25 09:50:34.039313405 +0200
+++ websockets-tls.py	2012-10-25 12:13:54.947045338 +0200
@@ -509,7 +509,11 @@
 
         # Connect the transport to our factory, and make things go. We need to
         # do some stupid stuff here; see #3204, which could fix it.
-        transport.protocol = protocol
+        if request.isSecure():
+            # Secure connections wrap in TLSMemoryBIOProtocol too.
+            transport.protocol.wrappedProtocol = protocol
+        else:
+            transport.protocol = protocol
         protocol.makeConnection(transport)
 
         return NOT_DONE_YET
