在NodeJS中的Socket.io

我在一个NodeJS应用程序中使用socket.iosocket.io页面位于localhost:8081/socket.io/ 。 不过,我想在localhost:8081/hola/socket.io/ 。 那可能吗?

 var express = require("express"); var app = express(); var server = require("http").Server(app); var io = require("socket.io")(server); //some code here... server.listen(8081, function() { console.log("Server running at http://localhost:8081/"); }); 

只需传递给socket.io的第二个选项options数组中的path即可:

 var io = require("socket.io")(server, { path: '/hola/socket.io'});