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

   $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 <[email protected]> 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
>  * [email protected]
> 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
  * [email protected]
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

Reply via email to