我正在尝试在带有节点的CodeIgniter项目中实现sockets.io 我的server.js文件:
var express=require('express');
var app=express();
var server=require('http').createServer(app);
var io=require('socket.io').listen(server);
//connect server to port
var listener=server.listen(process.env.PORT || 80,function(){
console.log('Listening on port ' + listener.address().port);
});
和客户端:
<script type="text/javascript" src="assets/js/node_modules/socket.io-client/dist/socket.io.js"></script>
$(function(){
var socket = io.connect('http://localhost');
console.log(socket);
});
但是我得到
EIO = 3&transport = polling&t = MHvYqNg 404(未找到)
错误 我做错了什么? 请帮忙 预先感谢