客户端: var url = "ws://localhost:8088"; w = new WebSocket( url ); //事件监听 w.onopen = function() { console.log(“open”); } w.onclose = function(e) { console.log( “closed” ); }
服务端:
var socket = require( ‘socket.io’ );
var io = socket.listen( 8088 );
io.set('log level’, 1);
io.sockets.on('connection’, function ( socket ) {
console.log( socket );
});
WebSocket connection to ‘ws://localhost:8088/’ failed: Connection closed before receiving a handshake response 为什么在握手前就断开连接了?