连接到node.js socket.io服务器:客户端不连接 – 服务器报告“销毁nonsocket.io升级”

我以为socket.io将允许我实现一个websocket服务器。 我有这个非常简单的代码:

// Require HTTP module (to start server) and Socket.IO var http = require('http'), io = require('socket.io'); // start at port 8888 var server = http.createServer(function(req, res) { res.writeHead(200,{'Content-Type': 'text\html'}); res.end('<h1>Welcome to the Notification Server</h1>'); }); server.listen(8888); // Create Socket.io obj/pass to server var socket = io.listen(server); socket.on('connection', function(client) { console.log('Successful Websocket connection!'); client.on('message', function(event) { console.log("Received message from client", event); }); client.on('disconnect', function() { console.log('Client has disconnected'); }); }); 

我已经尝试了几个不同的testing客户端,所有这些客户端都在服务器上生成这个消息: debug – 销毁nonsocket.io升级

一个这样的客户端尝试有这样的代码:

 <html> <script type="text/javascript"> <!--- window.WebSocket = window.WebSocket || window.MozWebSocket; var ws = new WebSocket("ws://dev.ourserver.com:8888"); ws.onopen = function() { alert("Connected"); } ws.onerror = function(error) { alert("Error:"+error); } // --> </script> <body> </body> </html> 

只要我们加载页面,我得到服务器上的debugging消息。

我认为这个库的重点是支持websocket协议,任何支持websocket的客户端都可以连接。

如果我从字面上解释消息,似乎表明server.io已经检测到它正在连接到一个“非socket.io”客户端。 这是否意味着我不能在客户端使用socket.io连接到此服务器?