Hi All, 

I  am having a weird problem with t_relay when calling it from route[2] in
the script below.

The problem that I am experiencing is that it does not relay the message to
the modified destination uri host/port. Instead it relays the message to the
modified uri/host/port from route[1]. 

I initially thought the problem was with my tncgw_route custom module that
modifies the msg->new_uri
but after some testing and debugging I realized that if I modify the
destination uri host/port with rewritehostport functino on route[2]
t_relay() is also failing (sending the message to the modified uri in
route[1]).

Then I decided to try t_relay("udp:host:port") instead of t_relay() on
route[2] and it worked fine. So the question is why does t_relay() is not
picking the msg->new_uri when called from route[2]?.  

route[1] {
        setflag(22);
        # send it out now; use stateful forwarding as it works reliably
        # even for UDP2TCP
        
        if (method=="INVITE"){
                t_on_failure("1");
                t_on_reply("1");

                $var(route_result)=tncgw_route("1");
                tncgw_cdr();
                
                if($var(route_result)==-404){
                        xlog("Invalid Route send 404 \n");
                        sl_send_reply("404","Invalid Route");
                        tncgw_releasecdr("404","SB Invalid Route");  
                        exit;
                        
                }

                if($var(route_result)==-503){
                        xlog("Congestion, send 503 \n");
                        sl_send_reply("503","No route available for 
destination");
                        tncgw_releasecdr("503","SB No route available for 
destination");  
                        exit;
                        
                }

                if($var(route_result)<0){
                        xlog("Call not routed\n");
                        sl_send_reply("503","No route available for 
destination");
                        tncgw_releasecdr("$var(route_result)","SB Call not 
routed");  
                        exit;
                }


                t_relay();
                exit;   
        }
}

route[2] {
        setflag(22);
        # send it out now; use stateful forwarding as it works reliably
        # even for UDP2TCP
        t_on_reply("2");
        $var(route_result)=tncgw_route("2");
             tncgw_cdr();

        if($var(route_result)==-404){
                xlog("Invalid Route send 404 \n");
                sl_send_reply("404","Invalid Route");
                tncgw_releasecdr("404","SB Invalid Route");  
                exit;
        }

        if($var(route_result)==-503){
                xlog("Congestion, send 503 \n");
                sl_send_reply("503","No route available for destination");
                tncgw_releasecdr("503","SB No route available for 
destination");  
                exit;
        }

        if($var(route_result)<0){
                xlog("Call not routed\n");
                sl_send_reply("503","SB No route available for destination");
                tncgw_releasecdr("$var(route_result)","SB Call not routed");  
                exit;
        }

        if (!t_relay()){
        
                sl_reply_error();

        };
}

failure_route[1] {
        setflag(22);
        if(status=~"3[0-9][0-9]|4[0-9][0-9]|5[0-9][0-9]|6[0-9][0-9]")
        {
                /*
                if first carrier failed the call then try the next in route
                */
                append_branch();
                route(2);
                exit;
        }
}


onreply_route[1] {
        setflag(22);
        if (status=~"3[0-9][0-9]|4[0-9][0-9]|5[0-9][0-9]|6[0-9][0-9]") {
                # Response from carrier
                tncgw_releasecdr("$rs","From Carrier");
        }

}

I appreciate any help.

Thank you.

Chevio

-- 
View this message in context: 
http://n2.nabble.com/Problem-with-t_relay-after-tp2450413p2450413.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.


_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to