I'm learning about Asterisk::AMI module in perl to connect to asterisk. While running the following program I can't connect to asterisk. can anyone give me solution to solve this issue?.
use Asterisk::AMI;
my $astman = Asterisk::AMI->new(PeerAddr => '127.0.0.1', #Remote host address
PeerPort => '5038', #Remote host port
#AMI is available on TCP port 5038 if you enable it in manager.conf.
Username => 'admin', #Username to access the AMI
Secret => 'supersecret' #Secret used to connect to AMI
);
die "Unable to connect to asterisk" unless ($astman);
my $action = $astman->({ Action => 'Command',
Command => 'sip show peers'
});
print $action;
Thanks in advance.
Your script should show errors/warnings if you include:
use warnings;
at the start of your script.