简体   繁体   中英

SocketIO and Apache

I configured a classic socket.io server :

var http = require('http');
var fs = require('fs');

// Chargement du fichier index.html affiché au client
var server = http.createServer();

// Chargement de socket.io
var io = require('socket.io').listen(server);
var nbUsers = 0;
// Quand on client se connecte, on le note dans la console
io.sockets.on('connection', function (socket) {
    nbUsers++;

    socket.emit('users',nbUsers);
    socket.broadcast.emit('users',nbUsers);

    socket.on('disconnect', function(){ 
        nbUsers--;
        socket.broadcast.emit('users',nbUsers); 
    });

});


server.listen(1337);
console.log("Server started at port 1337"); 

And, in the index.php page, I call the socket.io.js :

<script src="http:// mysite . com:1337/socket.io/socket.io.js"></script>

But, when I go to the main page, I got an 504 error on socket.io.js. Any explanation ?

Thanks

尝试以这种方式包括socket.io

<script src="socket.io/socket.io.js"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM