title: Client disconnects immediately (Chrome Extension Websocket Client + NodeJS Server)
body: <p>I am trying to connect with websocket from a chrome 17 extension to a local nodejs server. After creation </p>
  
  <p>var websocket = new WebSocket("ws://localhost:7055");</p>
  
  <p>After succcessful creation of the websocket instance I receive immediately the onClose event.</p>
  
  <p>A check if websocket is supported is true.</p>
  
  <p>if ("WebSocket" in window) 
       log("Websockets are supported here "); </p>
  
  <p>WHAT IS THE PROBLEM HERE ? I hope anybody can help me with this issue.</p>
  
  <p>The browser is generally able to run websockets, I have tested it
  with </p>
  
  <p><a href="http://websocket.org/echo.html" rel="nofollow">http://websocket.org/echo.html</a></p>
  
  <p>Also the 'Dark WebSocket Terminal' (Google Extension) shows the same
  behaviour connecting to ws://localhost:7055/</p>
  
  <p>I tried it also with ws://127.0.0.1:7055/, same result</p>
  
  <h2>client code (Chrome 17 extension)</h2>
  
  <pre><code>runSockets("ws://localhost:7055");
  
  function runSockets(wsUri) {
  if ("WebSocket" in window) 
      log("Websockets are supported here "); 
  
  var websocket = new WebSocket(wsUri);
  log("Web Socket created with the state "+ websocket.readyState);
  
  websocket.onopen = function(evt) { onOpen(evt) };
  websocket.onclose = function(evt) { onClose(evt) };
  websocket.onmessage = function(evt) { onMessage(evt) };
  websocket.onerror = function(evt) { onError(evt) };
  }
  
  function onOpen(evt) {
    log("CONNECTED");
    doSend("WebSocket connected");
  }
  
  function onClose(evt) {
    log("DISCONNECTED");
  }
  
  function onMessage(evt) {
    log("RESPONSE: " + evt.data);
    websocket.close();
  }
  
  function onError(evt) {
    log("ERROR: " + evt.data);
  }
  
  function doSend(message {
    log("SENT: " + message); 
    websocket.send(message);
  }
  </code></pre>
  
  <h2>server code (nodejs v0.6.11)</h2>
  
  <pre><code>var http = require('http');
  
  http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\r\n');
  }).listen(7055, 'localhost');
  
  console.log('Server running at http://localhost:7055/');
  </code></pre>