【问题标题】:How to check error in omegle integration with nodejs (UNHANDLED EXCEPTION)?如何检查 omegle 与 nodejs 集成中的错误(未处理的异常)?
【发布时间】:2026-01-01 22:20:06
【问题描述】:

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

【问题讨论】:

    标签: javascript node.js websocket


    【解决方案1】:

    这个错误是因为你的 Internet 连接与 Omegle 超时,所以它可以很容易地处理尝试阅读 npm/Omegle 网站和 Github 中的 Callium Rogers 文档,使用 Try ctach over the function。

    【讨论】:

    • 我已经阅读了文档并且没有关于这个错误的任何内容。我也使用了 try catch,但在我的情况下它根本不起作用。