opensips 1.7 as Stateful redirect server

Stefan
2011-12-05
2013-05-09
  • Stefan

    Stefan - 2011-12-05

    Hi,
    I am creating a redirect server with the following snippet fails to send a reply INCLUDING a new contact header in 302 redirect reply  when I use stateful service.
    # rewrite current URI, which is always part of destination ser. What is wrong in the snippet for statefull redirect server?

        DOES NOT WORK 
    if (t_newtran()) {
            append_branch("sip:sbc_xyz@alternative.com");
            t_reply("302","Redirect");
    } else sl_reply_error();

    When I use stateless service, the contact header IS added correctly in the 302 redirect

    WORKS FINE
    # append one more URI to the destination ser
           append_branch("sip:redirect@alternative.com:9");
            # redirect now
           sl_send_reply("302", "Redirect");

    Thanks in advance

     
  • Bogdan-Andrei Iancu

    Hi Stefan,

    I just made a small test with 1.7 branch and the Contact hdr was properly added. The script was exactly your snapshot:

    route {

       if (t_newtran()) {
            append_branch("sip:sbc_xyz@alternative.com");
            t_reply("302","Redirect");
       }   else sl_reply_error();

    }

    Regards,
    Bogdan

     
  • Stefan

    Stefan - 2011-12-20

    Thank you very much Bogdan for your reply

    I solved my problem in the mean time by the following snippet:

    $avp(contact)="sip:"+$avp(normcdn)+"@"+$avp(ogtrkgrp); # where normcdn is some e.164 number and ogtrkgrp is a FQDN
    $ru=$avp(contact);           #change existing ruri

    if (t_newtran()) {
    t_reply("302","Redirect, stateful");
    } else sl_reply_error();

    This works fine but I don't understand why -according to existing opensips examples and documentation -another branch should be created (previous snippet) rather then just changing the ruri. What is the difference and what is best current practice?

    regards
    Stefan

     
  • Bogdan-Andrei Iancu

    Hi Stefan

    Logically it is the same and as said, I tested the append_branch() approach and it worked for me.
    Regarding your code, you can simplify it like:
       $ru  = "sip:"+$avp(normcdn)+"@"+$avp(ogtrkgrp);

    Regards,
    Bogdan

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks