socket.io与nodejs没有find所需的js文件

我将我的应用程序部署到no.de. 我与socket.io的第一个问题是,我不得不改变它正在听的端口。

io = require('socket.io').listen(3000), 

现在更改端口后,无法find所需的脚本socket.io.js

  script(src="/socket.io/socket.io.js") 

我尝试和绝对的path在港口,以及但没有奏效。 在本地主机上它工作得很好,所以我很困惑如何解决这个问题。

  GET http://twtups.no.de/socket.io/socket.io.js 404 (Not Found) Uncaught ReferenceError: io is not defined 

第二次看我的日志显示这/ /这是从快递我想,不知道如果有关

  Warning: connection.session() MemoryStore is not designed for a production environment, as it will leak memory, and obviously only work within a single process. [ Jan 11 11:10:09 Method "start" exited with status 0. ] 

更新,像这样工作

 var app = express.createServer(); var io = require('socket.io').listen(app); app.listen(80); 

你使用什么Express版本

API已经从Express 2.x更改为3.x,所以答案在从2.x迁移到3.x wiki的Socket.IO兼容性部分:

Socket.IO的.listen()方法将http.Server实例作为参数。
从3.x开始express()的返回值不是http.Server实例。 要使Socket.IO与Express 3.x一起工作,请确保手动创build并将http.Server实例传递给Socket.IO的.listen()方法:

 var app = express() , http = require('http') , server = http.createServer(app) , io = require('socket.io').listen(server); server.listen(3000); 

我不知道发生了什么(它应该工作),但你总是可以尝试把socket.io.js放在你的主站点上的某个地方。

其实端口的改变只对WebSocket服务器有用。 当您导入socket.io ,/ socket.iourl会自动添加到您的应用程序中,因此该文件仍在您的主站点上提供。 你说的话似乎很奇怪,也许和no.de有关。 我不确定。