Hello sr-users,
We're using Kamailio to proxy to a number of FreeSWITCH backend servers
with the dispatcher module.
In some specific scenarios it matters to which node the request is sent.
In these cases we've configured FS to respond to the invite with 302 and
provide a custom header which contains the uri of the needed backend
server (Intending to emulate the behaviour of 305 Use Proxy).
To attempt to handle this I've tried the following in kamailio:
onreply_route[MANAGE_REPLY] {
...
if (t_check_status("302") and
is_present_hf("X-imx-redirect"))
{
$avp(imx-redirect) = $hdr(X-imx-redirect);
xlog("SCRIPT: REDIRECT, Store avp for redirect:
$avp(imx-redirect)\n");
}
}
Then in the dispatch failure route:
if ($avp(imx-redirect) != $null)
{
$du = $avp(imx-redirect);
xlog("SCRIPT: REDIRECT: going to <$ru> via
<$du>\n");
route(RELAY);
exit;
}
Which results in the following sip event sequence:
// Normal invite sequence
FS1 -> Kamailio SIP/2.0 302 Moved Temporarily (X-imx-redirect = sip:FS2...)
Kamailio -> FS1 ACK
Kamailio -> Caller SIP/2.0 407 Proxy Authentication Required
Then the caller generates a new INVITE however I'm unsure how to route
this INVITE to the specific node. The avp appears (intentionally) tied
to the transaction so doesn't seem to be able to be used to correlate in
this scenario.
Advice on how to redirect from a backend server to another specific
backend server behind Kamailio would be greatly appreciated.
Cheers,
-nick