Summary:ASTERISK-12781: Calls originated from AMI do not have channel variables specified in sip.conf set
Reporter:agjohnson (agjohnson)Labels:
Date Opened:2008-09-26 12:35:58Date Closed:2008-12-10 14:13:46.000-0600
Versions:Frequency of
Environment:Attachments:( 0) 13565.diff
Description:Console output:
Executing [s@macro-zap-out:2] NoOp("SIP/nottiano-0845a458", "User_ID: ") in new stack

exten => s,n,NoOp(User_ID: ${User_ID})


Calls originated through the AMI does not have the variable set.  Calls originated from the SIP peer do have the variable set.
Comments:By: Leif Madsen (lmadsen) 2008-10-01 11:38:05

I was able to reproduce this behaviour. However I'm not entirely sure this isn't wrong (although not expected...)

The way I reproduced this was to configure 2 SIP channels; phone1 and phone2.

Then via the Manager, I originated a call to phone1, and attached to a simple diaplan to call phone2:

exten => 102,1,NoOp(${User_ID} value)
exten => 102,n,Dial(SIP/phone2)
exten => 102,n,Hangup()

If I call from phone1 to phone2 by dialing 102, then I get this:

   -- Executing [102@testing:1] NoOp("SIP/phone1-08d48378", "phone2 value") in new stack
   -- Executing [102@testing:2] Dial("SIP/phone1-08d48378", "SIP/phone2") in new stack
   -- Called phone2

If however I originate the call from the Manager, I get the following:

   -- Executing [102@testing:1] NoOp("SIP/phone1-08d48378", " value") in new stack
   -- Executing [102@testing:2] Dial("SIP/phone1-08d48378", "SIP/phone2") in new stack
   -- Called phone2

(The value of ${User_ID} is either 'phone1' or 'phone2' respectively).

The reason I think this might not necessarily be wrong (although I agree it might be nice to have that data), is because the Manager is Originating a call to 'phone1'. Once that call is connected, then Asterisk is executing the dialplan as passed to the Manager, and then bridges the two calls together.

But it is not actually SIP/phone1 that is generating the call -- it is Asterisk. So the code that needs to be executed prior to firing the call off to phone2 I'm sure isn't being executed, and thus is the reason why you're not getting your value.

Here is what I pass to the Manager:

Action: Originate
Channel: SIP/phone1
Exten: 102
Context: testing
Priority: 1

Hopefully a developer can take a look at this and determine if there is a way to pass the variable, or at least explain why that is not possible.


By: Jason Parker (jparker) 2008-11-20 16:12:34.000-0600

Your description sounds accurate.

Can't you set variables in a manager Originate somehow?

By: agjohnson (agjohnson) 2008-11-24 10:45:29.000-0600

You can, if you know the information.  In my particular case, it isn't very practical to have the machine sending the originate command to query for this information.

By: Joshua C. Colp (jcolp) 2008-12-10 14:13:45.000-0600

As blitzrage mentioned the setvar option is for calls *into* Asterisk. I have, however, attached a patch that will give you the behavior you seek.