Skip to content

Instantly share code, notes, and snippets.

@getify
Created October 5, 2011 04:07
Show Gist options
  • Select an option

  • Save getify/1263609 to your computer and use it in GitHub Desktop.

Select an option

Save getify/1263609 to your computer and use it in GitHub Desktop.
trouble getting socket.io to work in node
xx.yy.zz.ww GET 200 application/javascript 234B 72ms
278839520115563000 GET 101 undefined 30B 2.0min
278839520115563000 GET 200 text/plain 159B 2.3min
278839520115563000 GET 200 text/javascript 166B 20.40s
278839520115563000 GET 200 text/javascript 166B 20.06s
278839520115563000 GET 200 text/javascript 166B 20.07s
278839520115563000 GET 200 text/javascript 166B 20.08s
278839520115563000 GET 200 text/javascript 166B 20.07s
278839520115563000 GET (failed) undefined 30B 1.6min
278839520115563000 GET 200 text/plain 159B 20.09s
278839520115563000 GET 200 text/plain 159B 20.12s
278839520115563000 GET 200 text/plain 159B 20.06s
278839520115563000 GET (canceled) undefined 30B 5.03s
var socket = io.connect("http://xx.yy.zz.ww");
socket.on('news', function(data,success){
console.log("DATA!");
success("yes");
});
//socket.emit('my other event', { my: 'data' });
info - socket.io started
debug - served static /socket.io.js
debug - client authorized
info - handshake authorized 278839520115563206
debug - setting request GET /socket.io/1/websocket/278839520115563206
debug - set heartbeat interval for client 278839520115563206
debug - client authorized for
debug - websocket writing 1::
connection established!
debug - websocket writing 5:1+::{"name":"news","args":[{"hello":"world"}]}
debug - setting request GET /socket.io/1/xhr-polling/278839520115563206?t=1317787153942
debug - setting poll timeout
debug - discarding transport
debug - cleared heartbeat interval for client 278839520115563206
debug - setting request GET /socket.io/1/jsonp-polling/278839520115563206?t=1317787164043&i=1
debug - setting poll timeout
debug - discarding transport
debug - clearing poll timeout
debug - clearing poll timeout
debug - jsonppolling writing io.j[1]("8::");
debug - set close timeout for client 278839520115563206
debug - jsonppolling closed due to exceeded duration
debug - setting request GET /socket.io/1/jsonp-polling/278839520115563206?t=1317787184457&i=1
debug - setting poll timeout
debug - discarding transport
debug - cleared close timeout for client 278839520115563206
debug - clearing poll timeout
debug - jsonppolling writing io.j[1]("8::");
debug - set close timeout for client 278839520115563206
debug - jsonppolling closed due to exceeded duration
debug - setting request GET /socket.io/1/jsonp-polling/278839520115563206?t=1317787204519&i=1
debug - setting poll timeout
debug - discarding transport
debug - cleared close timeout for client 278839520115563206
debug - clearing poll timeout
var app = require('http').createServer(function(req, res){
res.writeHead(200);
res.end("Nothing to see here, folks.");
}),
io = require('/usr/local/lib/node_modules/socket.io').listen(app)
;
app.listen(80, "xx.yy.zz.ww");
io.configure(function(){
io.enable('browser client minification'); // send minified client
io.enable('browser client etag'); // apply etag caching logic based on version number
// io.set('log level', 1); // reduce logging
io.set('transports', [ // enable all transports (optional if you want flashsocket)
'websocket'
, 'flashsocket'
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
]);
});
io.sockets.on('connection', function (socket) {
console.log("connection established!");
//socket.on('my other event', function (data) {
// console.log("DATA:"+data);
//});
socket.emit('news', { hello: 'world' }, function(data) {
console.log("received:"+data);
});
});
@getify
Copy link
Author

getify commented Oct 6, 2011

I've tried "on-message" and it still doesn't work. I even tried it where it's same-domain, and still it won't work.

i'm convinced it's something about my server setup, but for the life of me i can't figure out what.

@groovecoder
Copy link

sorry man, I'm out of ideas. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment