title: Can't get browser to connect to nodejs WS server if not localhost
body: <p>I've been struggling to figure out what I don't understand:  I have a NodeJS websocket server running on a computer on my local network. From that computer's browser, I can communicate with the websocket server. However, from any other computer on the same network, I get a forced closeEvent with error code 1006.</p>
  
  <p>Attached are both server and client files. The client file is also being served from the same place.  Any help in broadening my understanding here would be most greatly appreciated.</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <h2>ws_server.js</h2>
  
  <pre><code>var fs = require('fs');
  var path = require('path');
  var httpServer = require('http').createServer(
      function(request, response) {
          if(request.url != ''){//request.url is the file being requested by the client
              var filePath = '.' + request.url;
              if (filePath == './'){filePath = './ws_client.html';} // Serve index.html if ./ was requested
              var filename = path.basename(filePath);
              var extname = path.extname(filePath);
              var contentType = 'text/html';
              fs.readFile(filePath, function(error, content) {
                  response.writeHead(200, { 'Content-Type': contentType });
                  response.end(content, 'utf-8');
              });
          }
      }
  ).listen(8080);
  
  var WebSocketServer = require('ws').Server;
  var wss = new WebSocketServer({server:httpServer});
  wss.on('connection', function(ws) {
      ws.on('message', function(message) {
          console.log('received: %s', message);
          ws.send("You said: "+ message);
      });
  });
  </code></pre>
  
  <hr>
  
  <h2>ws_client.html</h2>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;WS&lt;/title&gt;
      &lt;script&gt;
          var connection = new WebSocket('ws://127.0.0.1:8080');
          connection.onopen = function () {connection.send("The time is " + new Date().getTime());};
          connection.onmessage = function (e) {document.getElementById("capture").innerHTML = e.data;};
          connection.onclose = function(event) {console.log(event);};
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;textarea id="capture"&gt;&lt;/textarea&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>