0
我正在做一个geddy框架(基本聊天示例)的实时应用程序。但是,当客户端尝试建立连接时,我会收到错误消息。geddy与socket.io错误
这里的服务器端代码(在init.js文件):
var io = require('socket.io').listen(geddy.server);
io.sockets.on('connection', function (socket) {
console.log("Good!");
socket.emit('new', { message: 'world' });
socket.on('newMessage', function (data) {
console.log(data);
});
});
和客户端代码:
$(document).ready(function(){
startSockets();
});
function startSockets(){
var socket = io.connect('http://localhost:4004');
socket.on('new', function (data) {
alert(data);
//socket.emit('newMessage', { my: 'data' });
});
}
当我尝试连接到本地主机:4004 /我得到的下一个警告:
debug - setting request GET /socket.io/1/websocket/G_GapksVv1J4iBZIUVe3
debug - set heartbeat interval for client G_GapksVv1J4iBZIUVe3
debug - websocket writing 7:::1+0
warn - client not handshaken client should reconnect
info - transport end (error)
debug - set close timeout for client G_GapksVv1J4iBZIUVe3
debug - cleared close timeout for client G_GapksVv1J4iBZIUVe3
debug - cleared heartbeat interval for client G_GapksVv1J4iBZIUVe3
debug - discarding transport
除了Chrome的控制台给出了这样的错误:
WebSocket is closed before the connection is established.
我不知道什么会导致这些。有任何想法吗?