Closed celevra closed 9 years ago
There is a connect() & disconnect() method that you could use on your AMI instance.
yes but how do i know when i got disconnected? is there an event?
Are you having problems to keep the connection alive?
we are starting and stopping asterisk very often because it is our development system. If we do so, the node application gets disconnected and doesn't reconnect automaticly, i'm searching for a way to reconnect automaticly or ifinitly
So it's the perfect timing for you test the improvement I'm doing: https://github.com/pipobscure/NodeJS-AsteriskManager/issues/30
Make sure to call AMIInstance.keepConnected();
var ami = new require('asterisk-manager')('5038','127.0.0.1','admin','xxx', true);
ami.keepConnected();
ami.on('confbridgejoin', function(evt) {
console.log('NEW JOIN');
console.log(evt.conference+', '+evt.calleridnum);
});
ami.on('confbridgeleave', function(evt) {
console.log('NEW LEAVE');
console.log(evt.conference+', '+evt.calleridnum);
});
ami.on('confbridgetalking', function(evt) {
console.log('TALKÍNG');
console.log(evt);
});
when i do service asterisk restart
i get the following error:
Error: connect ECONNREFUSED at errnoException (net.js:904:11) at Object.afterConnect as oncomplete
before all that i've done a git clone in the node_modules folder
Yes, the error will be logged but the important thing is that your code is still running correctly. is it?
no it isn't, sorry
What stopped working?
Everything works fine before the restart and after it stops ?
I've tested those scenarios and everything works fine... :/
[]'s Igor
On 02/12/2014, at 18:47, celevra notifications@github.com wrote:
no it isn't, sorry
— Reply to this email directly or view it on GitHub.
i start the mentioned code with node asterisk.js
then i restart asterisk and after it's stopped it drops the error and exits
is there something else i can provide?
Yeah, this is happening because you're not handling the exception: http://nodejs.org/docs/latest/api/process.html#process_event_uncaughtexception
process.on('uncaughtException', function(err) {
console.log('Caught exception: ' + err);
});
Try absorbing this exception and test it again.
I think that my tests are working fine because I am handling those exceptions.
@celevra Did it work?
works like a charm! Thank you very much!
Hi,
thank you very much for this library. I've wasted half a live with a php library... but is there something like a disconnect event or a reconnect mechanism?
regards
celevra