I've been playing around with socket.io (very much a newbie), my goal is to post data to the server, do a small database entry and return data to the user real time.
My default server is nginx currently.
I've been looking at the example on socket.io, but this is only when wanting to use node.js to handle everything.
When trying to listen on port 3000, I get a warning of:
server:
var io = require('socket.io').listen(3000);
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
client:
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://localhost:3000');
socket.on('news', function (data) {
console.log(data);
socket.emit('my other event', { my: 'data' });
});
</script>
I simply want to push the data from my web page to the node server, but whenever I do currently, I get a 404 for the socket.io/socket.io.js file. I've looked in to this, and other answers suggest having an update to date version of the node module express? I've ensured I have the latest versions of node.js, socket.io and express installed on my server.
Is there anywhere obvious where I'm going wrong here, sorry if this is an obvious question.