title: ws4py.websocket: Closing connection from client long delay
body: <p>I created a secure WebSocket server using the ws4py.websocket package.</p>
  
  <p>A javascript client connects to this Websocket and sends some JSON messages to it.</p>
  
  <p>Now when my JS client closes the connection (<code>function disconnect</code>), it takes about 30 secondes before the server's <code>closed</code> function gets called</p>
  
  <p>Here's the code:</p>
  
  <p><strong>Server</strong></p>
  
  <pre><code>class ControlWebSocket(WebSocket):
  
      def opened(self):
          print("Client connected")
  
      def closed(self, code, reason=None):
          print("Connection closed [%d]" % (code))
  
      def received_message(self, m):
          #some business logic using 'm'
  server = make_server('', 8999, server_class=WSGIServer, handler_class=WebSocketWSGIRequestHandler, app=WebSocketWSGIApplication(handler_cls=ControlWebSocket))
  server.socket = ssl.wrap_socket (server.socket, certfile='./cert.pem', keyfile='key.pem', server_side=True)
  server.initialize_websockets_manager()
  server.serve_forever()
  </code></pre>
  
  <p><strong>Client</strong></p>
  
  <pre><code>ws = new WebSocket("wss://192.168.42.1:8999/");
  
  ws.onopen = function() {
      console.log("Connected to WebSocket server");
  };
  
  ws.onmessage = function(e) {
      //some business logic using e
  };
  
  ws.onclose = function() {
      console.log("Disconnected from WebSocketServer");
  };
  
  function disconnect() {
      console.log("Disconnecting from WebSocketServer");
      ws.close();
  }
  </code></pre>
  
  <p>Any clues on why this is so long to close the connection ? Are there any ways to terminate the connection faster ?</p>