title: Websocket server running fine but cannot connect from client (what url should I use?)
body: <p>OK this is very simple to anyone who's used <strong>websocket</strong> and <strong>nodejs</strong>.
  I have created a websocket server named <strong>ws_server.js</strong> and put it in <strong>C:\Program Files (x86)\nodejs</strong> where I have installed the nodejs framework.  I started the server and it is running and it says it's listening on port 8080.  So far so good, I have the server running.</p>
  
  <p>Now I simply want to connect to it from client code so that I can do all that lovely stuff about capturing events using event listeners etc.  The problem is, embarassingly, I cannot figure out what URL to use to connect to my websocket server.</p>
  
  <pre><code>function init() { 
      testWebSocket(); 
  }  
  
  function testWebSocket() { 
      websocket = new WebSocket("ws://localhost:8080/"); // WHAT URL SHOULD BE USED HERE? 
      websocket.onopen = function(evt) { alert("OPEN") }; 
  
      websocket.onclose = function(evt) { alert("CLOSE") }; 
      websocket.onmessage = function(evt) { alert("MESSAGE") }; 
      websocket.onerror = function(evt) { alert("ERROR") }; 
  }  
  
  function doSend(message) { 
      // this would be called by user pressing a button somewhere
      websocket.send(message); 
      alert("SENT");
  }  
  
  window.addEventListener("load", init, false);  
  </code></pre>
  
  <p>When I use ws://localhost:8080 the only events that trigger are CLOSE and ERROR.  I cannot get the client to connect.  I must be missing something very simple.  Do I need to set up my nodejs folder in IIS for example and then use that as the URL?</p>
  
  <p>Just to reiterate, the websocket server is running fine, I just don't know what URL to use to connect to it from the client.</p>
  
  <p>EDIT: The websocket server reports the following error.
  <strong>Specified protocol was not requested by the client.</strong></p>