title: Socket.io and Redis Pub/Sub not working
body: <p>Hello guys i would like to figure out what is the error in my code, my code is about socket.io and redis pub/sub it is my first time to try this, I hope you can help me guys.</p>
  
  <p>This is my <strong>index.html</strong></p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
      &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
      &lt;script&gt; 
          var socket = new io.Socket();
          socket.connect();
  
          socket.on('connection', function (socket) {
              console.log('Connected');
          });
  
          socket.on('disconnect', function (socket) {
              console.log('Disconnected');
          });
      &lt;/script&gt;
      &lt;center&gt;
      &lt;h1&gt;Test Page&lt;/h1&gt;
      &lt;/center&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my <strong>app.js</strong></p>
  
  <pre><code>var redis = require('redis');
  var app = require('http').createServer();
  var io = require('socket.io').listen(app);
  var client = redis.createClient();
  var pub = redis.createClient();
  var sub = redis.createClient();
  
  app.listen(1234);
  
  io.sockets.on('connection', function (socket){
      sub.on('subscribe', function (channel){
          pub.publish('Pub','Test Message 1');
          pub.publish('Pub','Test Message 2');
          pub.publish('Pub','Test Message 3');
      });
      sub.on('message', function (channel, message) {
          console.log(channel + ':' + message);
      sub.unsubscribe();
      pub.end();
      sub.end();
      });
      sub.incr('Channel Test');
      sub.incr('Pub');
  });
  </code></pre>
  
  <p>I hope you can help me fix this code. Thanks in advance guys.</p>