title: NodeJS socket.io event fired from client side but not receiving on server
body: <p>I am building a simple turn based game in node.js and I had everything working 100% running with a locally hosted mongoDB, the socket events were working fine, however when i changed from a local db (using mongo) to mLab mongoDB hosting it stopped working, i could still log in and register accounts correctly, the database was still returning the exact same results, so it is obviously having no trouble connecting and querying the database. But i'm completely lost at what the problem could be. When i change the database URL it would never fire the socket.emit('key') event; </p>
  
  <p>However it does fire the ('find match') event on the client socket but the server never handles it. (it doesn't log "findMatch" on server).</p>
  
  <p>the server is logging "connection" but never receiving any other socket events. </p>
  
  <p>Even if i don't get a solution i am just completely stuck trying to debug where the problem is occurring, so any sort of input would be really really appreciated</p>
  
  <p>This is socket debug log i'm getting in console.</p>
  
  <pre><code>//--------------------------------------------------------------------------------------------------------------
  looking for match
  socket.io-1.2.0.js:1 socket.io-client:manager writing packet %j +3s Object {type: 2, data: Array[1], nsp: "/"}
  socket.io-1.2.0.js:1 socket.io-parser encoding packet %j +2s Object {type: 2, data: Array[1], nsp: "/"}
  socket.io-1.2.0.js:1 socket.io-parser encoded %j as Object +0ms 2["findMatch"]
  socket.io-1.2.0.js:1 engine.io-client:socket flushing 1 packets in socket +2s
  //--------------------------------------------------------------------------------------------------------------
  
  
  var express = require('express');
  app = express();
  http = require('http').Server(app);
  io = require('socket.io').listen(http);
  mongoose = require('mongoose');
  passport = require('passport');
  flash = require('connect-flash');
  morgan = require('morgan');
  bodyParser = require('body-parser');
  cookieParser = require('cookie-parser');
  session = require('express-session');
  methodOverride = require('method-override');
  User = require('./models/user');
  
  
  var configDB = require('./config/database.js');
  mongoose.connect(configDB.url);
  
  mongoose.connection.on('error', console.error);
  
  app.use(express.static('public', {redirect: false}));
  app.use(express.static('private/tests', {redirect: false}));
  
  
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({extended: true}));
  //app.use(methodOverride());
  app.use(cookieParser());
  app.set('view engine', 'ejs');
  
  require('./config/passport')(passport);
  
  app.use(session({secret: 'password'}));
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(flash());
  
  passport.serializeUser(function(user, done) {
      done(null, user.id);
  });
  
  // used to deserialize the user
  passport.deserializeUser(function(id, done) {
      User.findById(id, function(err, user) {
          done(err, user);
      });
  });
  
  
  require('./routes')(app,passport);
  
  var rooms = [];
  
  
  io.sockets.on('connection', function(socket){
      console.log("connection");
  
      socket.on('key', function(data){
          console.log("key");
          socket._id = data.user_id;
          socket.nickname = data.username;
          socket.rank = data.rank;
  
          socket.on('findMatch', function() {
              console.log('findMatch');
              //do some other stuff
          });
  </code></pre>
  
  <p>And then on the client side i have this setup</p>
  
  <pre><code>scotchApp.controller('lobbyController', function ($scope, $http) {
      $http.get('/play').then(function successCallback(results){
          socket.on('connect',function(){
              console.log("emit key")
              socket.emit('key',{
                  user_id: results.data._id,
                  username: results.data.local.email,
                  rank: results.data.local.rank,
              });
          });
  
          $scope.findMatch = function(){
              console.log('looking for match');
              socket.emit('findMatch')
          };
  </code></pre>