Hello,
as a general note, not al functions support variables in the parameters,
depends of their associated fixup c function that is used at startup.
Usually, docs specify if the function supports variables in the
parameters, most of them support them as part of a dynamic string
parameter (e.g., "sip:$rU@domain.com").
In this particular case, the variant t_relay(host, port) came in via
merging SER project back in 2008 and it is an alternative to the
t_relay_to_udp/tcp/...(host, port) by using same protocol for outgoing
as the incoming message. All t_relay_to_udp/tcp/...(host, port)
functions require static value parameters because it resolves the host
at startup and converts everything in a binary (runtime optimized) proxy
address that's used for each of their execution. So there is no support
for variables as parameters, as they don't have the value available at
startup or their value can change any time.
If you don't need to relay always to same destination, then this
function is not suitable. Alex's suggestion is one way to do it.
Cheers,
Daniel
On 05.01.22 10:36, Alex Balashov wrote:
Hi Nick,
I think it might be worthwhile to ask why you want to provide these arguments to
t_relay(), even though it can take them.
There is a common and understandable misconception among new users that specifying these
arguments is the way to tell Kamailio the destination to which a message should be
relayed. In fact, it’s not the canonical way it is done.
t_relay() consumes the domain part of the request URI ($ru):
$ru = “sip:" + $rU + "@10.0.1.1:5060”;
# or
$rd = “10.0.1.1”;
If the domain in the RURI is different than the desired network destination, the
“destination URI” can be used to override this:
https://www.kamailio.org/wiki/cookbooks/5.5.x/pseudovariables#du_-_destinat…
$du = “sip:10.0.1.1:5060”;
These values can of course be constructed from variables as well.
So, it is likely the case that you don’t need to call t_relay() with arguments at all.
:-)
— Alex
On Jan 5, 2022, at 3:21 AM, Nick J
<nick(a)nickvsnetworking.com> wrote:
Hi all,
I've been banging my head on the table with this one and hoping someone has some
insight here.
I'm trying to use a variable as the host & port input in t_relay() -
t_relay(host, port)
This works fine if statically set:
t_relay("10.0.1.1", "5060");
But if I change the host or the port to a variable like this:
$avp(destip) = "10.0.1.1";
$avp(dstport) = "5060";
t_relay($avp(destip), $avp(dstport));
Then Kamailio fails to start, calling out the t_relay line:
kamailio: CRITICAL: <core> [core/cfg.y:3686]: yyerror_at(): parse error in config
file /etc/kamailio/kamailio-routelogic.cfg, line 62, column 35: bad command
I get the same behavior with pseudovariables and vars as well:
$var(destip) = "10.0.1.1";
$var(dstport) = "5060";
t_relay($var(destip), $var(dstport))
Any tips or pointers would be much appreciated.
Thanks!
Nick
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
* sr-users(a)lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
*
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users --
Alex Balashov | Principal | Evariste Systems LLC
Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
Web:
http://www.evaristesys.com/,
http://www.csrpswitch.com/
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
* sr-users(a)lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
*
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla --
www.asipto.com
www.twitter.com/miconda --
www.linkedin.com/in/miconda
Kamailio Advanced Training - Online
Feb 21-24, 2022 (America Timezone)
*
https://www.asipto.com/sw/kamailio-advanced-training-online/