[asterisk-users] AMI perl daemon

Alex Balashov abalashov at evaristesys.com
Mon May 16 14:58:27 CDT 2011


On 05/16/2011 03:48 PM, vip killa wrote:

> yes, it's originating the call and never responding.

This sounds to me like a possible problem with the Asterisk::AMI module, 
although I am unsure what the problem is, since I am not familiar with 
its internal architecture and have never used it.

To debug, try initiating the AMI connection and issuing the Originate 
statement raw:

    use IO::Socket;

    ...

    my $mgr_sock = IO::Socket::INET->new(
                      'PeerAddr' => '127.0.0.1',
                      'PeerPort' => 5038,
                      'Type' => SOCK_STREAM,
                      'Protocol' => 'TCP',
                      'Timeout' => 5);

    print $mgr_sock
      "Action: login\r\n" .
      "Username: XXXXXXXXXX\r\n" .
      "Secret: XXXXXXXXXX\r\n" .
      "\r\n";

    sleep(1);

    ...

    print $mgr_sock
      "Action: Originate\r\n" .
      "Channel: Local/$row[2]\@outbound\r\n" .
      "Context: page\r\n" .
      "CallerID: $row[1]\r\n" .
      "Exten: $row[1]\r\n" .
      "Priority: 1\r\n" .
      "Async: 1\r\n" .
      "\r\n";

    while(defined($mgr_sock) && $_ = <$mgr_sock>) {
            print;
    }

    sleep(1);

    close $mgr_sock;

-- 
Alex Balashov - Principal
Evariste Systems LLC
260 Peachtree Street NW
Suite 2200
Atlanta, GA 30303
Tel: +1-678-954-0670
Fax: +1-404-961-1892
Web: http://www.evaristesys.com/



More information about the asterisk-users mailing list