By default, the Local channel will try to optimize itself out of the call path. This means that once the Local channel has established the call between the destination and Asterisk, the Local channel will get out of the way and let Asterisk and the end point talk directly, instead of flowing through the Local channel.
This can have some adverse effects when you're expecting information to be available during the call that gets associated with the Local channel. When the Local channel is optimized out of the call path, any Dial() flags, or channel variables associated with the Local channel are also destroyed and are no longer available to Asterisk.
We can force the Local channel to remain in the call path by utilizing the /n directive. By adding /n to the end of the channel definition, we can keep the Local channel in the call path, along with any channel variables, or other channel specific information.
For example, if we were calling a Local channel from the Dial() application, we could change:
Dial(Local/201@devices)
...into the following line:
Dial(Local/201@devices/n)
By adding /n to the end, our Local channel will now stay in the call path and not go away.
Lets take a look at an example that demonstrates when the use of the /n directive is necessary. If we spawn a Local channel which then performs another Dial() to a SIP channel, but we use the L() option (which is used to limit the amount of time a call can be active, along with warning tones when the time is nearly up), it will be associated with the Local channel, which is then optimized out of the call path, and thus won't perform as expected.
Here is an overview of our call flow, and the information associated with the channels:
Now, if we were to modify our dialplan at step three (3) then we would force the Local channel to stay in the call path, and the L() option associated with the Dial() from the Local channel would remain, and our warning sounds and timing would work as expected.
There are two workarounds for the above described scenario:
Dial(Local/2@services,,L(60000:45000:15000))
lmadsen 2010-03-04