title: How to cleanly disconnect from a namespace in socket.io?
body: <p>I have been trying to disconnect from a namespace or even from the main socket connection itself but have been failing. Below is my code</p>
  
  <p>Server Side:</p>
  
  <pre><code> socket.on('userDisconnect', function () {        
      socket.disconnect();
      console.log("User Disconnected");       
  
  }); 
  </code></pre>
  
  <p>Client Side:</p>
  
  <pre><code>// already connected to /world namespace
  socket.emit('userDisconnect');
      socket.disconnect();
  socket = io.connect('http://something/india' );
  </code></pre>
  
  <p>I tried disconnecting from both client and serve side but it doesnt work. Can anyone point out the mistake.
  This is what is been written to console by socket.io</p>
  
  <pre><code>   info  - booting client
   debug - websocket writing 0::/world
  User Disconnected
     debug - client authorized for /india
     debug - websocket writing 1::/india
  </code></pre>
  
  <p>/world is the namespace its trying to disconnect from and then its trying to connect to /india namespace.</p>