浏览器端varsocket=io.connect('http://localhost:3000');服务器端varexpress=require('express');varroutes=require('./routes/index');varuser=require('./routes/user');varchat=require('./routes/chat');varhttp=require('http');varpath=require('path');varMongoStore=require('connect-mongo')(express);varsettings=require('./settings');varflash=require('connect-flash');varmulter=require('multer');varapp=express();app.set('port',process.env.PORT||3000);app.set('views',path.join(__dirname,'views'));app.set('viewengine','ejs');app.use(flash());app.use(express.favicon());app.use(express.logger('dev'));app.use(express.json());app.use(express.urlencoded());app.use(express.methodOverride());app.use(express.cookieParser());app.use(express.session({secret:settings.cookiesSecret,key:settings.db,cookie:{maxAge:1000*60*60*24*30},store:newMongoStore({db:settings.db})}));app.use(multer({dest:'./public/images/user',rename:function(fieldname,filename){returnfilename;}}));app.use(app.router);app.use(express.static(path.join(__dirname,'public')));app.use(express.static(path.join(__dirname,'bower_components')));if('development'==app.get('env')){app.use(express.errorHandler());}routes(app);varserver=http.createServer(app);vario=require('socket.io')(server);io.on('connection',function(){console.log('connection')});server.listen(app.get('port'),function(){console.log('Expressserverlisteningonport'+app.get('port'));});出错这个错误:RequestURL:http://localhost:3000/socket.io/1/?t=1420622609420StatusCode:400BadRequest服务器返回的错误信息是:{"code":0,"message":"Transportunknown"}这是什么情况?求大神解答~~~
相关分类