title: WebSocket handshake in Node.JS, Socket.IO and Clusters not working
body: <p>I having a problem with clustering my application with Node.js, socket.io and node.js clusters.</p>
  
  <p>I using the socket.io-redis to share the information for all workers, but is not working.</p>
  
  <p>My code:</p>
  
  <pre><code>var cluster   = require('cluster');
  var numCPUs = require('os').cpus().length;
  
  if (cluster.isMaster) {   
    // Fork workers.
    for (var i = 0; i &lt; numCPUs; i++) {      
      cluster.fork();
    }
  
    cluster.on('exit', function(worker, code, signal) {
      console.log('worker ' + worker.process.pid + ' died');
    });
  } else {
  
      ...
  
           var express   = require("express");
           //Server
           var server = express();
           //Socket.io
           var http  = require('http').Server(server);
           var io    = require('socket.io')(http);
           var redis_io = require('socket.io-redis'); 
           var redis = require("redis");
  
           io.adapter(redis_io({host: "127.0.0.1", port: 6379 })); 
  
      ...
  }
  </code></pre>
  
  <p>In client, i get errors in handshake like 400 error or WebSocket is closed before the connection is established. </p>
  
  <p>What i can do to solve this?</p>
  
  <p>Im using the last version of node.js and socket.io</p>
  
  <p>Thanks!</p>