gpt4 book ai didi

javascript - 如何检查 omegle 与 nodejs 集成中的错误(未处理的异常)?

转载 作者:行者123 更新时间:2023-11-30 17:59:42 26 4
gpt4 key购买 nike

我在 nodejs 中使用 omegle 集成,我有一个连接到 omegle 客户端的程序,接收他的消息并将其作为转发器发回(只是为了检查连接是否正常工作)。此时会发生未处理的错误,迫使服务器关闭。我该如何处理下面的这个错误??我用过 try, catch, finally 还有 nodejs 提供的 uncaughtException 方法..帮帮我...!!

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();

最佳答案

此错误是因为您与 Omegle 的 Internet 连接超时,因此可以轻松处理它尝试阅读 npm/Omegle 网站和 Github 中的 Callium Rogers 文档,在函数上使用 Try ctach。

关于javascript - 如何检查 omegle 与 nodejs 集成中的错误(未处理的异常)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17321466/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com