Hello, assuming that I want to use contact from 302 response as outbound proxy but keep the original Request-URI, what should I do? Calling the revert_uri() after get_redirects() in failure_route doesn't do the trick.
Hello,
On 1/25/12 2:56 PM, Andrew Pogrebennyk wrote:
Hello, assuming that I want to use contact from 302 response as outbound proxy but keep the original Request-URI, what should I do? Calling the revert_uri() after get_redirects() in failure_route doesn't do the trick.
an option - get the contact header from 302 in failure route via $T_rpl($ct). Use its uri to set $du.
Alternative, set onreply_route and if it is 302 reply, take the contact uri and add it in an avp. Use that avp in failure route.
Cheers, Daniel
Daniel, thank you - method (2) works like a charm.
On 01/25/2012 03:16 PM, Daniel-Constantin Mierla wrote:
an option - get the contact header from 302 in failure route via $T_rpl($ct). Use its uri to set $du.
I was getting an error for some reason:
0(7860) ERROR: <core> [pvapi.c:516]: error searching pvar "T_rpl" 0(7860) ERROR: <core> [pvapi.c:720]: wrong char [$/36] in [$T_rpl($ct)] at [7 (5)]
version: kamailio 3.1.5
Alternative, set onreply_route and if it is 302 reply, take the contact uri and add it in an avp. Use that avp in failure route.
This works.
Regards, Andrew
Hello,
On 1/25/12 4:09 PM, Andrew Pogrebennyk wrote:
Daniel, thank you - method (2) works like a charm.
On 01/25/2012 03:16 PM, Daniel-Constantin Mierla wrote:
an option - get the contact header from 302 in failure route via $T_rpl($ct). Use its uri to set $du.
I was getting an error for some reason:
0(7860) ERROR:<core> [pvapi.c:516]: error searching pvar "T_rpl" 0(7860) ERROR:<core> [pvapi.c:720]: wrong char [$/36] in [$T_rpl($ct)] at [7 (5)]
version: kamailio 3.1.5
do you have tmx module loaded?
Cheers, Daniel
On 02/01/2012 12:11 PM, Daniel-Constantin Mierla wrote:
I was getting an error for some reason:
0(7860) ERROR:<core> [pvapi.c:516]: error searching pvar "T_rpl" 0(7860) ERROR:<core> [pvapi.c:720]: wrong char [$/36] in [$T_rpl($ct)] at [7 (5)]
version: kamailio 3.1.5
do you have tmx module loaded?
It was missing, I've figured it out later. I am now using $T_rpl($ct) and with failure_reply_mode set to 3 redirects work pretty fine for me.
But maybe the error above is not enough self-descriptive, for those who are not reading the docs :)
Thanks. Andrew
On 01/25/2012 08:56 AM, Andrew Pogrebennyk wrote:
Hello, assuming that I want to use contact from 302 response as outbound proxy but keep the original Request-URI, what should I do? Calling the revert_uri() after get_redirects() in failure_route doesn't do the trick.
Put the 302 Contact URI in the destination set instead, i.e. $du, not $ru. That will cause it to be relayed to the redirect destination on the network and transport level, but the logical target will remain the same.
On 01/25/2012 03:18 PM, Alex Balashov wrote:
Put the 302 Contact URI in the destination set instead, i.e. $du, not $ru. That will cause it to be relayed to the redirect destination on the network and transport level, but the logical target will remain the same.
Ok. I was thinking that uac_redirect is the way to go, but it seems there isn't much going on behind the scenes anyway, so assigning to $du is just as valid. Thanks. Andrew
Since this thread will probably end up in Google I''ll share my experience. I ended up with this"
if(t_check_status("301|302")) { #NOTE: must assign to $du to keep R-URI intact $var(contact) = $T_rpl($ct); $var(contact) = $(var(contact){nameaddr.uri}); $du = $var(contact); xlog("L_INFO", "Redirect from proxy intercepted - M=$rm R=$ru F=$fu T=$tu IP=$avp(s:ip):$avp(s:port) ($si:$sp) ID=$ci\n"); append_branch(); route(ROUTE_RELAY); exit; }
where route(ROUTE_RELAY) is merely a call t_relay_to("0x01") wrapped up in some logging. So far so good.
There was a problem when a new request target needed digest-ch'd the caller with 407. The redirect server by default relayed not 407 but 302 reply back. I've set tm modparam failure_reply_mode to 3 - voila!
http://kamailio.org/docs/modules/3.1.x/modules/tm.html#failure_reply_mode