This has been driving me a little nuts over the past day, and after extensive research I still can't figure out.
I setup a Socket.io as shown in this question Using socket.io in Express 4 and express-generator's /bin/www
In my server code (app.js
), I have the following:
io.on('connection', function (socket) {
console.log("connected!");
socket.emit('all',{});
});
Then in my client code (index.jade
), I have the following:
var socket = io();
socket.on('all', function (data) {
console.log("here");
});
Unfortunately, when visiting index.
GET / 200 398.555 ms - 3957
GET /stylesheets/style.css 304 1.913 ms - -
connected!
Basically, my server sees my client, but my client won't receive anything from my server?? Btw, if I try localhost in my io, I won't even see the "connected!" event.
var socket = io.connect('http://localhost:3000/');
socket.on('all', function (data) {
console.log("here");
});