node.js + express 使用socket.io 客户端出现socket.io.js 404的问题解决

最近学习node.js socket.io遇到如题问题,在百度google尝试stackoverflow中的几个解决方法未果后,发现控制台上有如下提示“Socket.IO's .listen() method takes an http.Server instance...https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x”,详细情况如下:

Socket.IO's .listen() method takes an http.Server instance as an argument. As of 3.x, the return value of express() is not anhttp.Server instance. (See the Application function section above.) To get Socket.IO working with Express 3.x, make sure you manually create and pass your http.Server instance to Socket.IO's .listen() method.

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

server.listen(3000);

在IO的listen方法参数改为http.createServer后便可解决。


转载于:https://www.cnblogs.com/arby/archive/2012/11/04/2754124.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值