Q: SocketIO connection refused I am trying to get socket IO to work, but I keep getting connection refused.  I guess connection refused is better than connection timeout, as refused mean's something is stopping it somewhere?
Anyway the code is from socketIO's tutorial website:
Client side, located in /home/server/nodejs/expressocket.js:
var app = require('http').createServer(handler)
var io = require('socket.io')(app);
var fs = require('fs');

app.listen(8000);

function handler (req, res) {
  fs.readFile(__dirname + '../public_html/socketio.htm',
  function (err, data) {
    if (err) {
      res.writeHead(500);
      return res.end('Error loading index.html');
    }

    res.writeHead(200);
    res.end(data);
  });
}

io.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});

And then server side located in /home/server/public_html/socketio.js
<!DOCTYPE html>
<head>
    <script src="https://cdn.socket.io/socket.io-1.3.4.js"></script>
</head>
<body>
    <h1>Socket IO Test</h1>
    <script>
    var socket = io('http://localhost:8000');
    socket.on('news', function (data) {
    console.log(data);
    socket.emit('my other event', { my: 'data' });
    });
    </script>
</body>
</html>

I've got the right port in there, and the server should be listening on that port.  But why is it getting refused?  

A: Instead of var socket = io('http://localhost:8000');,
use​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ var socket = io.connect('http://localhost:8000/');
also if you have used npm install you can use
<script src="http://localhost:8080/socket.io/socket.io.js"></script>
to access the socket.io library on the front-end
