Giter VIP home page Giter VIP logo

perl-asterisk-ami's Introduction

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.

perl-asterisk-ami's People

Contributors

revmischa avatar rrb3942 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

perl-asterisk-ami's Issues

Events not containing ActionIDs

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.

AnyEvent->loop method removed

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.

Problem with action() method

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...

get_response does not contain response

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)

######SCRIPT BEGIN

!/usr/bin/perl -w

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";

####SCRIPT END

-George

AMI disconnecting from asterisk after Originate

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.

Memory leak on frequently connect

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

recursive blocking wait detected

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?

Timeout never occurs

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);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.