[SR-Users] Contacts in 302

Diego Nadares dnadares at gmail.com
Thu Nov 2 23:40:16 CET 2017


Hi again,

I found a work around . Modifying $ru changes de first contact uri.

 if($var(routing)=~"redirect"){
                jansson_get("contacts_len", "$var(evmsg)",
"$var(contacts_len)");
                xlog("L_INFO", "Contacts len $var(contacts_len)");
                $var(i) = 0;

                *$var(first) = 0;*
                while ($var(i) < $var(contacts_len)){
                        jansson_get("contacts[$var(i)]", "$var(evmsg)",
"$var(contact)");
                        if ($var(first) == 0){
                               * $ru = $var(contact);*
                              *  $var(first) = 1;*
                        }
                        #Appending anyway because of the q param
                        append_branch($var(contact), "0.5");
                        $var(i) = $var(i) + 1;
                }
                send_reply("302", "Moved Temporarily");
                exit;
        }

Contact: *<1111 at 188.111.111.112 <sip%3A1111 at 188.111.111.112>>*, <
sip:1111 at 188.111.111.112>;q=0.5, <sip:1111 at 188.111.111.112>;q=0.5


I think this is not the better way. Any suggestion will be very appreciated.

Thanks again.

Diego


2017-11-02 18:11 GMT-03:00 Diego Nadares <dnadares at gmail.com>:

> Hi Guys,
>
> I'm generating a 302 reply from kamailio. In this 302 I append new
> branches with new
> contacts.
>
> if($var(routing)=~"redirect"){
>                 jansson_get("contacts_len", "$var(evmsg)",
> "$var(contacts_len)");
>                 xlog("L_INFO", "Contacts len $var(contacts_len)");
>                 $var(i) = 0;
>                 while ($var(i) < $var(contacts_len)){
>                         jansson_get("contacts[$var(i)]", "$var(evmsg)",
> "$var(contact)");
>                         append_branch($var(contact), "0.5");
>                         $var(i) = $var(i) + 1;
>                 }
>                 send_reply("302", "Moved Temporarily");
>                 exit;
>         }
>
> The problem i'm facing is that I can't delete the original contact  *<sip:1111 at 188.111.111.111:5060
> <http://sip:1111@188.111.111.111:5060>>*
>
> The resulting conctact:
>
> Contact: *<sip:1111 at 188.111.111.111:5060
> <http://sip:1111@188.111.111.111:5060>>*, <sip:1111 at 188.111.111.112>;q=0.5,
> <sip:1111 at 188.111.111.112>;q=0.5
>
> I all ready tried with remove_hf('Contact') and adding the new ones after
> that but it doesn't worke either.
>
> The problem is that one gw takes the first contact over and over again and
> never the other two.
>
> Thanks in advance.
>
> Diego.
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20171102/4b6e9c97/attachment.html>


More information about the sr-users mailing list