title: Node.JS - Simple Socket.IO example not working. Getting debug - served static content /socket.io.js (Mac OSX/Localhost)
body: <p>I just began with node.js a few days ago and I'm know trying to use socket.io module. But it is not working as I was expecting. The example I am trying to reproduce is this one :
  <a href="http://robdodson.me/blog/2012/06/04/deploying-your-first-node-dot-js-and-socket-dot-io-app-to-heroku/" rel="nofollow noreferrer">http://robdodson.me/blog/2012/06/04/deploying-your-first-node-dot-js-and-socket-dot-io-app-to-heroku/</a></p>
  
  <p>I know that the version of Express they are using is outdated so I updated my code to fit with the new versions of the modules they are using.</p>
  
  <p>The problem I have is that my client doesn't get what my server is emitting, here is my server-side code :</p>
  
  <pre><code>var express = require('express'),
  http = require('http'),
  app = express(),
  port = 8080, // Use 8079 for dev mode
  server = http.createServer(app).listen(process.env.PORT || port, function(){
      console.log('Express server listening on port %d in %s mode', server.address().port,             app.settings.env);
  }),
  io = require('socket.io').listen(server),
  routes = require('./routes');
  
  // Configuration
  
  app.configure(function() {
      app.set('views', __dirname + '/views');
      app.set('view engine', 'ejs');
      app.use(express.bodyParser());
      app.use(express.methodOverride());
      app.use(app.router);
      app.use(express.static(__dirname + '/public'));
  });
  
  app.configure('development', function() {
      app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
  });
  
  app.configure('production', function() {
      app.use(express.errorHandler());
  });
  
  // Heroku won't actually allow us to use WebSockets
  // so we have to setup polling instead.
  // https://devcenter.heroku.com/articles/using-socket-io-with-node-js-on-heroku
  io.configure(function () {
      io.set("transports", ["xhr-polling"]);
      io.set("polling duration", 10);
  });
  
  // Routes
  app.get('/', routes.index);
  
  var status = "All is well.";
  io.sockets.on('connection', function (socket) {
      io.sockets.emit('status', { status: status }); // note the use of io.sockets to emit but         socket.on to listen
      socket.on('reset', function (data) {
          status = "War is imminent!";
          io.sockets.emit('status', { status: status });
      });
  });
  </code></pre>
  
  <p>And here is client-side :</p>
  
  <pre><code>&lt;script src="http://localhost:8080/socket.io/socket.io.js"&gt;
      var socket = io.connect(document.location.href);
  &lt;/script&gt;
  &lt;div id="status"&gt;&lt;/div&gt;
  &lt;button id="reset"&gt;Reset!&lt;/button&gt;
  </code></pre>
  
  <p>So if I understood well, what I should get is "All is well" on the first time in the status div, and "War is imminent !" if I click reset.
  But all I get is nothing.</p>
  
  <p>I tried those answers but I can't see any differences between the solution code and mine, or sometimes it's just outdated :
   1. <a href="https://stackoverflow.com/questions/13222232/solved-node-js-socket-io-app-on-server-not-working-correctly">Node.js + socket.io: app on server not working correctly</a>
   2. <a href="https://stackoverflow.com/questions/12650299/nodejs-socket-io-setup-served-static-content-no-handshake-ubuntu-on-rackspac">NodeJS - Socket.IO Setup: served static content no handshake (Ubuntu on Rackspace Cloud Server)</a></p>
  
  <p>I tried all of the solutions that were given in the other subjects but it definitely won't work for me. 
  Every modules are correctly installed. I followed the steps given in the tutorial I followed at first.
  If anyone has any idea of what is going on or if anyone experienced the same issue you are welcome.</p>
  
  <p>Thanks.</p>