My node server and client are running on different ports(3001,5347 respectively). On client I had used,
var socket = io(\'http://127.0.0.1:3001\');
>
If running Express as follows:
var app = express();
var server = app.listen(3000);
So to start socket.io, we can do the following:
var io = require('socket.io').listen(server);
The problem was because of following code:
var http = require('http').Server(app);
var io = require('socket.io')(http);
The server object passed to socket.io was not the same as the server object I'm listening on.