1

私は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();
4

1 に答える 1

2

このエラーは、Omegle とのインターネット接続のタイムアウトが原因です。簡単に処理できるため、npm/Omegle Web サイトと Github にある Callium Rogers のドキュメントを読んでみてください。関数で ctach を使用してください。

于 2013-06-26T13:37:43.463 に答える