0

I'm playing around with socket.io and I'm trying trying to locate the different properties of the socket object on connection.

I've found this answer which showed me the socket.request.connection.remoteAddress property, but when I do a console.log of the socket.request.connection object, the remoteAddress isn't listed as a property..

Why does console.log not list all the properties? Is there a better method to show an object?

var io = require('socket.io').listen(server);

io.sockets.on('connection', function(socket){

    console.log(socket.request.connection.remoteAddress);   //works
    console.log(socket.request.connection); //Doesn't show remoteAddress or remotePort
    console.dir(socket.request.connection); //Same problem
});
Community
  • 1
  • 1
Rho
  • 370
  • 2
  • 10
  • perhaps console is skipping inherited or non-enumerable properties. Object.getOwnPropertyNames() will find hidden ones, for-in can find inherited ones. also, are you sure it's not listed? sometimes a lot of stuff flows by, overwhelming the screen line buffer of the console. – dandavis Sep 07 '14 at 17:30
  • I saved the server output to a log and there was no remoteAddress property in the file. I've found some luck using Object.getOwnPropertyNames and for-in to list the keys but not the values. I'll keep investigating those, thanks. – Rho Sep 07 '14 at 18:27

0 Answers0