
      //
      connection.onclose = function (reason, details) {

         console.log("Connection lost: " + reason);

      }

      // now actually open the connection
      //
      connection.open();
   </script>
</body>
</html>