rrb3942 / perl-asterisk-ami Goto Github PK
View Code? Open in Web Editor NEWA Perl module for interfacing with the Asterisk Management Interface.
Home Page: http://voipnerd.net
License: Other
A Perl module for interfacing with the Asterisk Management Interface.
Home Page: http://voipnerd.net
License: Other
Asterisk::AMI is Copyright (C) 2011 by Ryan Bullock ([email protected]) Asterisk::AMI ================ DESCRIPTION This module provides an interface to the Asterisk Manager Interface. It's goal is to provide a flexible, powerful, and reliable way to interact with Asterisk upon which other applications may be built. It utilizes AnyEvent and therefore can integrate very easily into event-based applications, but still provides blocking functions for use with standard scripting. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: AnyEvent version 5.0 or higher AnyEvent::Handle AnyEvent::Socket Digest::MD5 Scalar::Util Carp version parent Note on SSL Support: For SSL support you will also need the module that AnyEvent::Handle uses for SSL support, which is not a required dependency. Currently that module is 'Net::SSLeay' (AnyEvent:Handle version 5.251) but it may change in the future. Note on SSL Support for CentOS/Redhat: If the version of Net:SSLeay included in CentOS/Redhat does not work try installing an updated version from CPAN. LICENSE This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
When I perform an originate (async or not) with a nonblocking AMI client, I do receive an ActionID in the action callback, but not for any of the associated call events as described in the documentation. I need to track the status of my call, but it is impossible without the uniqueid or actionid being set in the related events.
I am new to perl programming trying to do some simple stuff with perl-Asterisk-AMI.
It might not be a bug but loop() method seems not to be working anymore. I've looked into AnyEvent code Impl::EV and noticed that sub loop has been removed about 3 months ago (Revision 1.23). It was actually removed from other AnyEvent implementations.
Hi, this is my first post here! The problem is that method action() won't work inside a sub, that was called for the Handler! When the program come to that method it won't go any further! The method send_action works just fine, when I replaced it on that spot!
Sorry for my rusty English...
Hello,
I'm trying to get familiar with your module so we can setup monitoring of our asterisk server. Using this script results in the following results. Can someone explain what I'm doing wrong please? Thank you
2
HASH(0x924720)
use Asterisk::AMI;
use Net::SSLeay;
my $astman = Asterisk::AMI->new(PeerAddr => 'host',
Username => 'user',
Secret => 'password',
UseSSL => '1'
);
die "Unable to connect to asterisk" unless ($astman);
my $actionid = $astman->send_action({ Action => 'Command',
Command => 'sip show peers'
});
my $response = $astman->get_response($actionid);
print "$actionid\n";
print "$response\n";
-George
Hello.
I'm using Asterisk::AMI in some auto-dialer script and facing some confusing problems with this module trying to keep event-style programming. I'm calling Originate through send_action() and waiting for event with type 'UserEvent', that have to be processed by callback function myHandler() i specified in Asterisk::AMI->new(). The problem is that in myHandler() i want to get some values from asterisk database. I've tried to do it using Asterisk::AMI::Common::db_get(), but it just hangs until timeout and returns nothing, while in asterisk CLI i see that there is no manager connected. The only way i found is to make new AMI connection in myHandler() and use db_get(), but i think, that is bad way. Can you help me?
I've also tried to send action 'DBGet' with send_action() with callback, it works well, i get the requested data, but I have no idea how to send this data back to function that called this action.
My test looks:
use EV;
use Asterisk::AMI;
my $w = EV::periodic 0, 5, 0, sub {
my $ami = Asterisk::AMI->new(
PeerAddr =>'127.0.0.1',
PeerPort => '5038',
Username => 'test',
Secret =>'test',
);
if ( !$ami ) {
return;
}
$ami->send_action(
{
'Action' => 'Command',
'Command' => 'core show channels count'
},
sub {
$ami->disconnect();
$ami = undef;
},
3
);
};
EV::loop;
it wiil see memory increasing every time, i test it on perl 5.10.1 and 5.18.2. and the moudles all the latest
EV: error in callback (ignoring): AnyEvent::CondVar: recursive blocking wait detected at /usr/local/share/perl/5.10.1/Asterisk/AMI.pm line 1131
What's that supposed to mean?
hi,
I've set up a simple loop in order to detect if the remote Asterisk is dead, and re-connect when that happens. However, after a successfull connect, when I pull the cable from the asterisk box, the timeout never occurs. packet trace shows that it's still doing TCP retransmission after more than 10 minutes.
while(1)
{
syslog(LOG_DEBUG, 'Connecting to GSM gateway');
$SIG{'TERM'} = sub {
syslog(LOG_INFO, 'Caught SIGTERM, stopping');
exit(1);
};
eval {
my $errsub = sub {my ($ami, $msg) = @_; die($msg)};
my $eventhandler = sub
{
my ($ami, $event) = @_;
syslog(LOG_DEBUG, Dumper($event));
};
my $astman = Asterisk::AMI->new(
'PeerAddr' => $gwhost,
'PeerPort' => $gwport,
'Username' => $gwuser,
'Secret' => $gwpasswd,
'Blocking' => 0,
'Keepalive' => 10,
'Timeout' => 5,
'TCP_Keepalive' => 1,
'on_connect_err' => $errsub,
'on_error' => $errsub,
'on_disconnect' => $errsub,
'on_timeout' => $errsub,
'on_connect' => sub{syslog(LOG_DEBUG, 'Connected')},
'Events' => 'on',
'Handlers' => { default => $eventhandler }
);
EV::loop;
};
if( $@ )
{
syslog(LOG_CRIT, $@);
}
syslog(LOG_INFO, 'Sleeping for 10 seconds');
sleep(10);
}
unsupported type passed to AnyEvent::Handle::push_read at /usr/local/lib/perl5/site_perl/5.10.0/Asterisk/AMI.pm line 788
I have the latest version of AnyEvent -
FYI - I am running asterisk 1.6
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.