I'm completely new to Node.JS and Socket.IO since yesterday.
I try to make Node.JS and Socket.IO work on my Raspberry Pi but it doesn't seem to. I can't access to <myip>:1337/socket.io/socket.io.js
.
I have followed this tutorial so my Lighttpd.conf file seems like so:
$HTTP["host"] == "<myURLtomywebsite>" {
proxy.server = (" " => ((
"host" => "<myIP>",
"port" => 1337)
)
)
My server.js
look like so:
var http = require('http');
httpServer = http.createServer(function(req, res) {
res.end('Hello World!');
});
httpServer.listen(1337);
var io = require('socket.io').listen(httpServer);
var clients = 0;
io.sockets.on('connection', function(socket) {
++clients;
socket.on('disconnect', function(data) {
--clients;
io.sockets.emit('disusr', clients);
});
io.sockets.emit('newusr', clients);
});
And I bind to the disusr
and newusr
events in my client.js
to display the number of connected users in a div
.
Everything looks fine on my localhost
but, in production environment, I cannot link to my socket.io.js
file on the 1337
port. To be honest, I'm not even sure what address to use? (URL of my website appended with :1337
, localhost
, some other address I would have created?)
Any help would be much appreciated. Thanks!