2013-06-26 21 views
1

我在nodejs中使用omegle集成,并且我有一个连接到omegle客户端的程序,接收他的消息并将其作为中继器发回(仅用于检查连接的正确工作)。虽然这是一个未处理的错误,强制服务器关闭。 我如何处理下面的这个错误? 我已经使用try,catch,finally以及nodejs提供的uncaughtException方法.. 帮我解决... !!如何检查与nodejs集成的错误(UNHANDLED EXCEPTION)?

ERROR--> 
event.js:72 
     throw er; // Unhandled 'error' event 
Error:connecr ETIMEDOUT 
     at errnoException (net.js:884:11) 
    at Object.afterConnect [as oncomplete] (net.js:875:19) 

我的代码 - >

 var Omegle, om, start; 
     Omegle = require('../lib/omegle').Omegle; 
     om = new Omegle(); 
     om.on('recaptchaRequired', function(key) { 
    return console.log("Recaptcha Required: " + key); 
}); 
om.on('gotMessage', function(msg) { 
    var repeat; 
    console.log("Got message: " + msg); 
    repeat = function() { 
    var sent; 
    sent = "You said: " + msg; 
    return om.send(sent, function(err) { 
     return console.log(!err ? "Message sent: " + sent : "Error: " + err); 
    }); 
    }; 
    om.startTyping(function() { 
    return console.log("We started typing"); 
    }); 
    return setTimeout(repeat, 800); 
}); 
om.on('strangerDisconnected', function() { 
    console.log("Stranger disconnected"); 
    return start(); 
}); 
om.on('typing', function() { 
    return console.log('Stranger started typing'); 
}); 
om.on('stoppedTyping', function() { 
    return console.log('Stranger stopped typing'); 
}); 
start = function() { 
    return om.start(function() { 
    return console.log("connected with id " + om.id); 
    }); 
}; 
start(); 

回答

2

这个错误是因为Omegle的您的Internet连接超时的,因此,它可以很容易地处理尝试读取NPM/Omegle的网站Callium罗杰斯文档并且在Github中,也可以在函数上使用Try ctach。

+0

我已阅读文档,并没有写有关此错误的地方.. 而且我也使用了try catch,但在我的情况下它根本不工作。 –