So, I have this very basic installation of socket.io, which you have probably seen a thousand times already.
Please, not that files were transferred through apache.
server (app.js)
var io = require('socket.io').listen(8080); io.sockets.on('connection', function(socket){ socket.emit('server ready', {msg: 'hi'}) ; socket.on('random event', function(data) { console.log('received'); }) });
and client
$(document).ready(function() { var socket = io.connect('http://127.0.0.1:8080/projectname/server/'); socket.on('server ready', function(data){ console.log('server ready!'); }); socket.emit('random event', {hurr: 'durr'}); });
However, the only way out I get is
debug - websocket writing 5:::{"name":"server ready","args":[{"msg":"hi"}]}
in the node console and nothing in the client console. It is not right.
I tried the basic example from socket.io and it shows exactly the same behavior. It logs the emitted data in the node console, but nothing else happens.
Edit: upon further research, visiting a site in Firefox generates another output in the node console:
info - handshake authorized 178702677759276313 debug - setting request GET /socket.io/1/xhr-polling/178702677759276313?t=1339080239192 debug - setting poll timeout debug - client authorized for debug - clearing poll timeout debug - xhr-polling writing 1:: debug - set close timeout for client 178702677759276313 debug - xhr-polling received data packet 17 1::/stock/server/ 66 5::/stock/server/:{"name":"random event","args":[{"hurr":"durr"}]} debug - setting request GET /socket.io/1/xhr-polling/178702677759276313?t=1339080239263 debug - setting poll timeout debug - clearing poll timeout debug - xhr-polling writing 5:::{"name":"server ready","args":[{"msg":"hi"}]}
It looks like the data received from the client actually reached the server. However, this problem does not seem to be resolved: the console.log lines and the client and server executable are not running. This output is from Firefox 5.0.1 , where it seems to be returning to xhr.
Many thanks!