[asterisk-dev] Dialplan AGI with SIP channels blocking if AGI already running - parallellism not possible?

Johan Sandgren jsa at svep.se
Thu Apr 4 05:13:53 CDT 2013


Thanks for the suggestions Anne.

I tried it, modified it a bit, and got it working. Happy! :)

If anyone else might need this in the future, this is how my solution looks like in the dialplan (about).

[sipmessage]
exten => 1000, 1,  ...storing the SIP MESSAGE details in db via javaprogram, returning the dbkey, storing in the variable dbkey
exten => 1000, n, Originate(Local/${dbkey}@messageProcessor,app,Echo)
exten => 1000, n, Hangup()

[messageProcessor]
exten => _X!,1, Set(dbkey=${EXTEN})
exten => _X!,n, NoOp("dbkey  ="${dbkey})
exten => _X!,n, Answer()	; This will release the Originate in 1000
exten => _X!, n,Agi(agi://localhost/sipmessageprocessor.agi?dbkey=${dbkey})
exten => _X!, n,Hangup()


-----Ursprungligt meddelande-----
Från: J.A. Bezemer [mailto:costar at wormhole.robuust.nl] 
Skickat: den 3 april 2013 20:57
Till: Johan Sandgren
Ämne: Re: [asterisk-dev] Dialplan AGI with SIP channels blocking if AGI already running - parallellism not possible?


On Wed, 3 Apr 2013, Johan Sandgren wrote:

> Thanks for the suggestion Matt,
> It works on behalf of the blocking is gone! Yes, celebration!!
>
> But, variable transfer between contexts when using Originate doesn't seem to happen.
> I tried different ways of setting my variable (with and without __, lower and caps chars), still NULL when received. The debug output in asterisk doesn't show any copying taking place either, so guess it might not happen at all.
[..]

> same => 1000,1,NoOp(Entry point for the message) ; Assuming you need 
> the message data, you could save them ; off into inheritable channel 
> variables same => n,Set(__MY_BODY=MESSAGE(body)) same => 
> n,Originate(Local/message_handler at default,app,Echo)

Pass value via the extension, like:

Originate(Local/message_handler-${MY_BODY}@default,app,Echo)

> same => n,Hangup()
>
> same => message_handler,1,NoOp()

same => _message_handler-.,1,Set(MY_BODY=${EXTEN:16})

..or something like that. Extension is limited to 79 chars though. If that's not enough, store message in database with random key, or in randomly named tempfile, pass the key/file name, and delete from the handler when finished.


Regards,

Anne Bezemer



-----Ursprungligt meddelande-----
Från: asterisk-dev-bounces at lists.digium.com [mailto:asterisk-dev-bounces at lists.digium.com] För Johan Sandgren
Skickat: den 3 april 2013 20:27
Till: Asterisk Developers Mailing List
Ämne: Re: [asterisk-dev] Dialplan AGI with SIP channels blocking if AGI already running - parallellism not possible?

Thanks again Matt.

I see there are 2 parameters to import (Note i'm using asterisk V10.0.0, it is supported I see in the docs. Ok) I can't find out how to get the channel to set as parameter 1, and the 2nd parameter, I'm guessing the format, not sure, since the docs is quite limited.

I don't succeed. I'm not sure I get the right Channel as well, If I print ${CHANNEL}, it shows "Local/

This is my dialplan for this I'm trying:

An incoming sip message enters in context sipmessage.

[sipmessage]
exten => 1000,1, Answer()
exten => 1000,n, NoOp("SIP-MESSAGE")
exten => 1000,n, NoOp(To ${MESSAGE(to)}) exten => 1000,n, NoOp(From ${MESSAGE(from)}) exten => 1000,n, NoOp(Body ${MESSAGE(body)})
exten => 1000,n, NoOp("Kanalnamn = " ${CHANNEL})    	; -> this outputs "Message/ast_msg_queue"
exten => 1000,n, NoOp(sip msg body=${MESSAGE(body)})		; I can print the SIP MESSAGE body here, it works.
exten => 1000, n, Originate(Local/message_handler at testhandler,app,Echo)
exten => 1000, n, Hangup()

[testhandler]
exten => message_handler,1,NoOp("testhandler")
exten => message_handler, n, NoOp("1 Imported value="IMPORT(${CHANNEL}, MESSAGE)		; returns "1 Imported value="IMPORT(Local/message_handler at scaiphandler-e3d2;2, MESSAGE"
exten => message_handler, n, NoOp("2 Imported value="IMPORT(${CHANNEL}, ${MESSAGE(body)})	; returns "2 Imported value="IMPORT(Local/message_handler at scaiphandler-e3d2;2, 
exten => message_handler,n, Answer()	; This will release the Originate in 1000
exten => message_handler, n,Agi(agi://localhost/sipmessageprocessor.agi?body=....SIP MESSAGE BODY when I get it right) exten => message_handler, n,Hangup()





-----Ursprungligt meddelande-----
Från: asterisk-dev-bounces at lists.digium.com [mailto:asterisk-dev-bounces at lists.digium.com] För Matthew Jordan
Skickat: den 3 april 2013 19:50
Till: asterisk-dev at lists.digium.com
Ämne: Re: [asterisk-dev] Dialplan AGI with SIP channels blocking if AGI already running - parallellism not possible?

On 04/03/2013 12:43 PM, Johan Sandgren wrote:
> 
> Thanks for the suggestion Matt,
> It works on behalf of the blocking is gone! Yes, celebration!! 
> 
> But, variable transfer between contexts when using Originate doesn't seem to happen.
> I tried different ways of setting my variable (with and without __, lower and caps chars), still NULL when received. The debug output in asterisk doesn't show any copying taking place either, so guess it might not happen at all.
> 
> Just for comparison, I used Dial instead of Originate. The blocking is back, but the inherent variables (prefix __) are copied, and it shows in the debug output of asterisk.
> 
> Is this a limitation, or a bug perhaps?
> Any suggestions for how to transfer the needed variable between contexts using Originate is appreciated.
> 

That's my fault; I had forgotten that Originating doesn't create a child channel but rather a new independent channel. Hence, variable inheritance does not apply.

You can use the IMPORT function [1] to pull the channel variables from the Message channel. You would want to do this before you Answer the Local channel, so as to prevent the Message channel from being hung up.

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Function_IMPORT


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



--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev



--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev





More information about the asterisk-dev mailing list