title: Socket.io client only joins room on every other connection
body: <p>I've been trying to make a basic notification system that uses rooms in Socket.io. However, for some reason, it only works every other time you refresh the page.</p>
  
  <p>I've simplified the code to make it easier to debug, but the issue remains. Each time I refresh the page, everything seems to work except joining a room (which only works half the time). What could be going on?</p>
  
  <p>edit: I'm using Socket.io version 1.1.0 and Node.js version 0.10.31
  edit2: Added FunnyLookinHat's suggestion (but it still doesn't solve the problem)</p>
  
  <p><strong>Client-Side Code:</strong></p>
  
  <pre><code>socket = io.connect('example.com:8081'),
  
  socket.on('connect', function () {
      socket.on('startup', function(data) {
          console.log(data.message);
      });
      socket.emit('joinRoom');
  });
  </code></pre>
  
  <p><strong>Server-Side Code:</strong></p>
  
  <pre><code>var io = require('socket.io').listen(8081);
  
  io.sockets.on('connection', function (socket) {
  
      console.log(socket.id + ' connected!');
  
      socket.emit('startup', { message: 'Socket started!' });
  
      socket.on('joinRoom', function(){
          console.log(socket.id + ' joining room lobby'); // prints on every other request
          socket.join('lobby');
      });
  
      socket.on('disconnect', function() {
          console.log(socket.id + ' disconnected!');
      });
  
  });
  </code></pre>
  
  <p><strong>Client Console:</strong></p>
  
  <pre><code>Socket started!
  
  (refreshed page)
  
  Socket started! 
  </code></pre>
  
  <p><strong>Server Console:</strong></p>
  
  <pre><code>UIBqVuOiF1fegMIMAAAB connected!
  UIBqVuOiF1fegMIMAAAB joining room lobby
  UIBqVuOiF1fegMIMAAAB disconnected!
  
  (refreshed page)
  
  x3nMilBOjjFVjBFJAAAC connected!
  
  (after about a minute once the client window has been closed or refreshed)
  
  x3nMilBOjjFVjBFJAAAC disconnected!
  </code></pre>