没有找到socket.io.js [英] socket.io.js not found
问题描述
由于某种原因,我的节点服务器无法提供路径 /socket.io/socket.io.js
,我总是收到404错误。
我尝试编译不同的节点版本(当前是0.6.13,它也运行在服务器上,实际工作)。
从app.js我得到 info:socket.io启动
,尝试调用socket.io.js时没有错误。
For some reason my node server cannot serve the route /socket.io/socket.io.js
, I always get a 404 error.
I tried compiling different node versions (current is 0.6.13 which also runs on server, where it actually works).
From the app.js I get info: socket.io started
and no error when trying to call the socket.io.js.
我从localhost和端口8000和我使用快速框架
I try it from localhost and port 8000 and I use the express framework
这是来自app.js的代码:
This is the code from app.js:
var express = require('express')
, app = require('express').createServer()
, io = require('socket.io').listen(app, { log: true });
app.listen(8000);
app.configure(function() {
app.use(express.static(__dirname + '/public'));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
io.sockets.on('connection', function (socket) {
// all other stuff here
推荐答案
请检查您的Express版本。Express最近更新为3.0alpha哪个API已更改,如果3.0,您可以将代码更改为喜欢这个:
Please check your Express version. Express recently is updated to 3.0alpha which API was changed. If 3.0 you can change your code to something likes this:
var express = require('express')
, http = require('http');
var app = express();
var server = http.createServer(app);
var io = require('socket.io').listen(server);
...
server.listen(8000);
连接相同的问题: https://github.com/senchalabs/连接/问题/ 500#issuecomment-4620773
这篇关于没有找到socket.io.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!