[asterisk-users] AMI Originate issue

Matthew Jordan mjordan at digium.com
Sat May 11 17:53:10 CDT 2013


On 05/11/2013 06:23 AM, Muhammad Faheem wrote:
> Hi,
> I'm getting an issue while executing AMI Originate. 
> I'm getting "extension does not exists" on Originate's Response, and on
> the other hand Asterisk CLI say "fwrite() returned error: Broken pipe"
> Please suggest me what is wrong.
> 
> Muhammad Faheem
> 
> ### my originate code block ...
> -----------------------------------------------------------------------------------------------
> # ami-script.pl <http://ami-script.pl>
> my $astman = Asterisk::AMI->new(PeerAddr => '127.0.0.1', PeerPort =>
> '5038', Username => 'faheem', Secret => 'secret');
>                         die "Unable to connect to asterisk" unless
> ($astman);
>                         my $resp_code = $astman->send_action({Action =>
> 'Originate',
>                                                         Channel =>
> 'Local/11223344',
>                                                         Context => 'users',
>                                                         Exten => 100,
>                                                         Priority =>1 });
>                         sleep(2);
>                         my $response = $astman->get_response($resp_code);
>                         print $response->{'Response'} ."\n";
>                         print $response->{'Message'} ."\n";
>                         $astman->disconnect ();
> 
> ####Script Output...
> *Error*
> *Extension does not exist*
> --------------------------------------------------------------------------------------
> ;extensions.conf
> ;;; Asterisk Dialplan 
> [default]
> exten => 11223344,1,NoOp("welcome")
> exten => 11223344,n,Answer()
> exten => h,1,NoOp("hangup...")
> 
> -----------------------------------------------------------------------------------------
> 

I don't use that particular AMI library so there may be other issues at
work here. However, some things do jump out:

1) You're originating a Local channel to 11223344, but you haven't
specified the context. While that *should* hit [default], it's usually a
good idea to specify both extension and context, i.e.,
Local/11223344 at default

2) Local channels are always created in pairs. You've directed that the
other half of the Local channel pair enter the dialplan in the [users]
context at extension 100, priority 1. Does that exist in your dialplan?
If not, that would probably be the cause of your problem.

3) The broken pipe is most likely from the call to 'disconnect' in your
AMI library. I would suspect that is terminating the TCP connection
while Asterisk is attempting to write an Event, causing the fwrite call
to fail. Either you or the library should probably be logging off using
the "Logoff" action prior to breaking the connection.

Note that you can always simulate what will occur when AMI performs an
Originate action by using the 'channel originate' CLI command.

Matt

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org





More information about the asterisk-users mailing list