I am using omegle integration in nodejs, and I've got a program which connects to an omegle client, receives his messages and sends it back as a repeater(just to check proper working of connection). While this an unhandled error occurs which forces the server to close. How can I handled this error below?? I have used try, catch, finally and also the uncaughtException method provided by nodejs.. Help me out...!!
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)
MY CODE-->
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();
This error is because of Timeout of your Internet Connection with Omegle, So it can be handled easily try to read the Callium Rogers documentation in npm/Omegle website and in Github too , use Try ctach over the function.