This should be trivial but is not working. We are trying to use a dialplan variable in the realtime switch statement in extensions.conf on Asterisk 18.8. If we can get the variable to work, we can do dynamic contexts with realtime
[incoming]
switch => Realtime/${DEVICE}@
${DEVICE} is a custom variable set in sip.conf using setvar
The below works if we hard code it
[incoming]
switch => Realtime/AAAA1@
We have used a NoOp statement to check that the ${DEVICE} variable is set correctly but its not being substituted in the switch => Realtime/${DEVICE}@
According to the code you use “eswitch” instead of “switch” to indicate it should be evaluated. The sample extensions.conf says this for it:
; An "eswitch" is like a switch but the evaluation of
; variable substitution is performed at runtime before
; being passed to the switch routine.
;
; eswitch => IAX2/context@${CURSERVER}
Thanks, we’ve now tried that but variable substitution still not working,
eswitch => Realtime/${DEVICE}@extensions
We just get the normal Notice message that the extension couldn’t be found in the context. We have verbose logging turned on. Any ideas how to debug this further.
Ok, done some further debugging and the problem is in
pbx_variables.c : 285
the following code
if (c) { /* This group requires a valid channel */
here c is null so no valid channel, so code doesn’t evaluate the variables, a backtrace is below
Why are you using a deprecated channel driver. Even if deemed a bug, this is not going to get fixed.
There is no point in using anything other than a global variable at this point, because chan_sip hasn’t created a channel, and without having created the channel, there can be no channel variables set at that point.
This test relates to a fixed set of variables that are really parameterless functions in disguise. ${DEVICE} is not one of them!
OK thanks, even ${EXTEN} doesn’t work, because as you say chan_sip hasn’t created a channel,
maybe I should retry this with chan_pjsip and if still not working, we can get the issue fixed
I’m not convinced that it will be accepted as a bug, Also, it’s rather unusual usage, and my understanding is that ARA is only community supported, so even if accepted as a bug, I think it very unlikely to get fixed in the foreseeable future, unless you are going to provide fully tested patches, yourself. It might require changes in almost every channel driver, that permits variables to be set at channel creation.
In any case, you should be able to use a GoTo in a static context. Although you may need to handle extension not found explicitly.
${EXTEN} is one of the “variables” that is really a parameterless function.
A general question - do you understand the ramifications of using realtime for a dialplan, the load it can place upon the database, and how any issues with the database become an issue in Asterisk resulting in call failure/calls hanging/etc?
Thanks for the response. We won’t be using any pattern matching in the database. We’ve seen warnings around that. The database will be a highly available setup. Other than that we will be testing performance before deploying. Our system is setup with multiple asterisk boxes fronted by opensips using the clustered database.