KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to get started with node.js and socket.io. I have a very ( very ) simple client-server test application and i can't get it to work. The system is set up on a windows machine with an apache server. The apache is running on port 81 and the the socket.io is set up to listen to port 8001 Server - server.js var io = require('socket.io').listen(8001); io.sockets.on('connection', function (socket) { console.log('\ngot a new connection from: ' + socket.id + '\n'); }); Client - index.html <!DOCTYPE html> <html> <head> <title>node-tests</title> <script type="text/javascript" src="http://localhost:8001/socket.io/socket.io.js"> </script> <script type="text/javascript"> var socket = io.connect('http://localhost', { port: 8001 }); socket.on('connect', function () { alert('connect'); }); socket.on('error', function (data) { console.log(data || 'error'); }); socket.on('connect_failed', function (data) { console.log(data || 'connect_failed'); }); </script> </head> <body> </body> </html> After starting my server using node server.js the standard (expected) output is written to the server console: info: socket.io started When I open index.html in the browser (chrome in my case - didn't test on other browsers) the following log is written to the server console: info: socket.io started debug: served static content /socket.io.js debug: client authorized info: handshake authorized 9952353481638352052 debug: setting request GET /socket.io/1/websocket/9952353481638352052 debug: set heartbeat interval for client 9952353481638352052 debug: client au
Tags (comma-separated)
Save Edits
Cancel