Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on initial login is silently ignored #58

Open
z3ntu opened this issue Mar 19, 2018 · 1 comment
Open

Error on initial login is silently ignored #58

z3ntu opened this issue Mar 19, 2018 · 1 comment

Comments

@z3ntu
Copy link

z3ntu commented Mar 19, 2018

var config = require('config');
var asterisk_manager = require('asterisk-manager');
var aConfig = config.get('asterisk');
var ami = new asterisk_manager(
    aConfig.port,
    aConfig.host,
    aConfig.username,
    aConfig.password,
    true);

When this is run and something (e.g. the password) is wrong, then the error is silently ignored (see https://github.com/pipobscure/NodeJS-AsteriskManager/blob/master/lib/ami.js#L50). Only after the object creation I can do

ami.on('error', function (err) {
    console.log(err);
});

to see the error. Is there another way I am not seeing?

@micodix
Copy link

micodix commented Oct 13, 2022

Hi,

the handler for errors caused by the socket connection is set here: https://github.com/pipobscure/NodeJS-AsteriskManager/blob/master/lib/ami.js#L82
The errors themselves are emitted here: https://github.com/pipobscure/NodeJS-AsteriskManager/blob/master/lib/ami.js#L87

To receive them, you must of course set an error listener in your code.

The code section you mentioned (https://github.com/pipobscure/NodeJS-AsteriskManager/blob/master/lib/ami.js#L49-L51) contains only listeners internally used by the manager instance for further processing of events. An error handler is obviously not needed (yet) at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants