Socket.io not sending data from client to server

I seem to be having a problem with communication from the client to the server using socket.io.

First, the JSON object I am sending

loginInfo = { email: 'username', password: 'password' }

On the client side I have:

socket.emit('user:login', loginInfo);

Then on the server side I have

socket.on('user:login', function(loginInfo) {
    console.log('data being sent is:\n' + loginInfo);
});

This prints out in the console:

data being sent is:
function ack() {
    self.log.debug('sending data ack packet');
    socket.packet({
        type: 'ack'
      , args: util.toArray(arguments)
      , ackId: packet.id
    });
}

Similarly if i do

socket.on('user:login', function(loginInfo) {
    console.log('data being sent is:\n' + loginInfo.password);
});

The console prints out:

data being sent is:
undefined

I have used socket.io in the past, and have never run into this issue before, so I must be doing something weird. If anyone knows the cause of this problem I'd be extremely grateful for insight on how to fix this issue.

Edit: The problem does not have to do with what is printing out, I was just using that to illustrate my problem, which is that the loginInfo JSON is either not being sent by the client properly or not being received by the server properly. My goal is to have the loginInfo be received by the server so I can process the data.

Thanks!

You need to stringify the object to append it to the string or else the behavior will be unpredictable:

console.log('data being sent is:\n' + JSON.stringify(loginInfo));

Is there a possibility that you have a function called loginInfo on the client side? I believe the socket.emit('user:login', loginInfo); line is sending a function instead of a parameter. A function as a parameter in socket.emit is used for getting acknowledgements.

Try making the array a property of an object... for whatever reason that worked for me;

messageIds = [1,2,3,4,5,6];

This did not work:

socket.emit('updateMessage',JSON.stringify(messageIds));

This did work:

  socket.emit('updateMessage',{1:messageIds});

Weird bug, not sure why.