[general]
enabled = yes
;webenabled = yes
port = 5038
;bindaddr = 0.0.0.0
bindaddr = 127.0.0.1
[Admin]
secret=admin@123
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan, originate,command
write = system,call,agent,user,config,command,reporting,originate,message,log,verbose
this is my manager.conf
const AsteriskAmi = require(“asterisk-manager”);
const amiConfig = {
host: “localhost”, //write_ your_asterisk-server_IP addr.
port: 5038,
username: “Admin”, // add_your_username of ami
password: “admin@123”, // add_your_password of ami
};
const ami = new AsteriskAmi();
// Connect to Asterisk AMI
ami.connect(amiConfig, (err) => {
if (err) {
console.error(‘Failed to connect to Asterisk AMI:’, err);
return;
}
else
{
console.log(‘Connected to Asterisk AMI’);
}
// Example: Sending a Ping action
ami.action({
Action: 'Ping'
}, (pingErr, res) => {
if (pingErr) {
console.error('Failed to send Ping command:', pingErr);
return;
}
console.log('Ping command sent successfully:', res);
});
// Example: Disconnecting from Asterisk AMI after a delay (for demonstration purposes)
setTimeout(() => {
ami.disconnect();
console.log(‘Disconnected from Asterisk AMI’);
}, 5000); // Disconnect after 5 seconds (adjust as needed)
});
// Handle connection close event
ami.on(‘close’, () => {
console.log(‘Connection to Asterisk AMI closed’);
});
// Handle error event
ami.on(‘error’, (err) => {
console.error(‘Asterisk AMI connection error:’, err);
});
this is my node js application to connect with Asterisk AMI but i got a error like this ** Connect attempt from ‘127.0.0.1’ unable to authenticate ** , please anyone guide me to solve this problem