[asterisk-users] Connecting two calls with Originate

Kathryn Jones kathrynster at gmail.com
Mon Aug 9 16:53:12 CDT 2010


I have been working on this for a while today, and still no luck. This is my
script:

#!/usr/bin/php
<?php
$errno=0;
$errstr=0;
$fp = fsockopen ("localhost",5038,$errno,$errstr,20);
if (!$fp) {
        echo "$errstr ($errno)<br>\n";
} else {

         fputs($fp, "Action: Login\r\n");
         fputs($fp, "Username: xxxx\r\n");
         fputs($fp, "Secret: xxxx\r\n");
         fputs($fp, "Events: off\r\n");
        sleep(1);
         fputs($fp, "Action: Originate\r\n");
         fputs($fp, "Channel: SIP/trunk/1DIDNumber\r\n");
         fputs($fp, "Context: CallContext\r\n\r\n");
         fputs($fp, "Exten: NumberToCall\r\n");
         fputs($fp, "Priority: 1\r\n");
         fputs($fp, "Timeout: 30000\r\n");
        sleep(2);
        fclose($fp);

}
?>

It seems simple enough, And I have no compilation errors. This is my output:

 -- Launched AGI Script /var/lib/asterisk/agi-bin/MyScript.php
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_request: MyScript.php
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_channel: SIP/xx.xx.xxx.xx-00000111
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_language: en
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_type: SIP
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_uniqueid: 1281390000.000
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_version: 1.6.2.6
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_callerid: 1PhoneThatCalled The DID
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_calleridname: unknown
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_callingpres: 0
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_callingani2: 0
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_callington: 0
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_callingtns: 0
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_dnid: IncomingExt
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_rdnis: unknown
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_context: default
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_extension: incomingExt
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_priority: 3
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_enhanced: 0.0
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_accountcode:
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> agi_threadid: -1237000000
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >>
  == Manager 'Man' logged on from 127.0.0.1
  == Manager 'Man' logged off from 127.0.0.1
<SIP/xx.xx.xxx.xx-00000111>AGI Rx <<
<SIP/xx.xx.xxx.xx-00000111>AGI Tx >> 510 Invalid or unknown command
[Aug  9 17:44:10] ERROR[25594]: utils.c:1128 ast_carefulwrite: write()
returned error: Broken pipe
[Aug  9 17:44:10] ERROR[25594]: utils.c:1128 ast_carefulwrite: write()
returned error: Broken pipe
    -- <SIP/xx.xx.xxx.xx-00000111>AGI Script MyScript.php completed,
returning 0

Could someone please point me in the right direction?



On Mon, Aug 9, 2010 at 11:15 AM, Danny Nicholas <danny at debsinc.com> wrote:

>   *From:* asterisk-users-bounces at lists.digium.com [mailto:
> asterisk-users-bounces at lists.digium.com] *On Behalf Of *Kathryn Jones
> *Sent:* Monday, August 09, 2010 11:22 AM
> *Subject:* Re: [asterisk-users] Connecting two calls with Originate
>
>
>
> On Mon, Aug 9, 2010 at 10:00 AM, Danny Nicholas <danny at debsinc.com> wrote:
>
> *>**>From:* asterisk-users-bounces at lists.digium.com [mailto:
> asterisk-users-bounces at lists.digium.com] *On Behalf Of *Kathryn Jones
> >>*Subject:* [asterisk-users] Connecting two calls with Originate
>
>
>
> >>Hello list!!
>
> >>I want to connect an open call with an extension. I call in with a DID,
> them redirect to the extension using AGI. Can I use agi's originate to make
> the second call >>without dropping the first DID call? How would I go
> about this?
>
> <snip>
>
>
> >>I am not having much luck, am I going about this the wrong way? Thanks
> in advance for your replies.
>
>
>
> ->Assuming that you’re not trying to dial back out on the same line, this
> should not be problematic.  The AGI originate is not necessarily aware that
> it is working in tandem with an existing call.  The “Channelopendidcall” is
> the “wrong way” part of this equation.  For example, if the call comes in on
> DAHDI/1-1, you can’t use DAHDI/1-1
>
> to open a second call whilst it is active;  you can make a call on
> DAHDI/1-2 and join the 2 together.
>
> >Wow, that was fast. Thanks for your reply!!!
>
> >So if I were to do:
>
> >Action: login
> >Username: xxxx
> >Secret: xxxx
> >Events: off
>
> >Action: Originate
> >Channel: SIP/trunk
> >Context: context-for-second-call
> >Exten: secondCall
> >Priority: 1
> >Callerid: CallerID
> >Timeout: 30
>
> >I could connect the 2 calls?
>
> As best as I know, yes this should work. You are actually creating a “new
> leg” with the originate, but the net effect is a joined call.
>
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>               http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100809/bfc19f45/attachment-0001.htm 


More information about the asterisk-users mailing list