node-webkit错误:未捕获,未指定的“错误”事件

时间:2013-04-27 04:59:21

标签: node.js websocket node-webkit

我收到了这个错误:

Error: Uncaught, unspecified 'error' event.
    at WebSocket.EventEmitter.emit (events.js:73:15)
    at Receiver.self._receiver.onerror (C:\programing\project\node_modules\ws\lib\WebSocket.js:566:10)
    at Receiver.error (C:\programing\project\node_modules\ws\lib\Receiver.js:301:8)
    at Receiver.processPacket (C:\programing\project\node_modules\ws\lib\Receiver.js:198:12)
    at Receiver.add (C:\programing\project\node_modules\ws\lib\Receiver.js:89:3)
    at Socket.firstHandler (C:\programing\project\node_modules\ws\lib\WebSocket.js:524:22)
    at Socket.EventEmitter.emit (events.js:96:17)
    at TCP.onread (net.js:397:14)  

node-webkit似乎运行最多2到4个小时,然后我收到上述错误。当node-webkit试图将数据包发送回wifly模块时,我不确定我的wifly模块是否超时导致过早断开连接。或者,如果通过web-socket protocal-76发送的数据包损坏,导致webkit模块无法理解发送的内容?我该怎么做才能解决这个错误?

websocket代码:

    var WebSocketServer = require('ws').Server, wss = new WebSocketServer({
        port : 8080
    });
    wss.on('connection', function(ws) {
        alert('connected!');
        ws.on('message', function(message) {
            //alert(message);
            $('#wsData').val(message);
            //console.log('received: %s', message);
        });
        ws.send('something', function(error){
            alert('Send error' + error);
        });
    });

添加后:

ws.on('error', function(error) { console.log(error); });

我收到消息:保留字段必须为空index.html:50
第50行代码:console.log(error);

0 个答案:

没有答案