[SR-Users] get_redirects with t_next_contacts

Marrold kamailio at marrold.co.uk
Tue Apr 5 01:14:14 CEST 2016


To not leave this thread forever unanswered, it turns out the above method
using t_next_contacts() was working as it should be, but as every contact
in the 302 redirect response was returning a 401, it tried all available
contacts and then ran out of options which resulted in  t_reply("408",
"Request Timeout MH 2");

This was due to my lazy regex whilst debugging. "[456][0-9][0-9]"

Apologies for the noise.


On Thu, Mar 31, 2016 at 11:57 AM, Marrold <kamailio at marrold.co.uk> wrote:

> I've found the following in an old thread that should help me debug, I
> will let the list know how I get on.
>
> pv_printf("$var(contact)", "$xavp(contacts[0]=>uri)");
> xlog ("L_NOTICE", "var(contact)=$var(contact)\r\n");
>
> On Thu, Mar 31, 2016 at 12:46 AM, Marrold <kamailio at marrold.co.uk> wrote:
>
>> Hi all,
>>
>> I am having some issues using get_redirects() from the UAC_Redirect
>> module in conjunction with  t_next_contacts from the TM Module. I've
>> searched Google and the list but the only references I can find are several
>> years old.
>>
>> I am attempting to configure Kamailio so it if receives a 3XX redirect
>> message, it will store the Contacts it contains, and attempt them in 'Q'
>> parameter order.
>>
>> So for the Contact below-
>>
>> Contact: <sip:10.0.97.21:5060>;q=0.2,<sip:5.29.13.139:5060>;q=0.5.
>>
>> I want Kamailio to try 5.29.13.139, and if that times out, or is rejected
>> in someway, try 10.0.97.21.
>>
>> If I use t_relay rather than t_next_contacts, kamailio branches the calls
>> and relays them in parallel regardless of Q value - this is not what I want.
>>
>> If I use t_next_contacts, it attempts 5.29.13.139 which is rejected with
>> a 401, but it doesn't attempt 5.29.13.139 and responds "408", "Request
>> Timeout MH 2"
>>
>> Relevant script section is below, has anyone been able to get this
>> working?
>>
>> failure_route[302] {
>>
>>     if (t_check_status("302")){
>>         xlog("L_ALERT","Failure Route: 302\n$mb");
>>
>>         get_redirects("*");
>>
>>         if (!t_load_contacts()) {
>>             send_reply("500", "Server Internal Error - Cannot load
>> contacts MH");
>>             exit;
>>         };
>>
>>         if (!t_next_contacts()) {
>>             t_reply("408", "Request Timeout MH");
>>         } else {
>>             t_on_failure("302");
>>             t_relay();
>>             exit;
>>         };
>>     } else if (t_check_status("[456][0-9][0-9]")){
>>
>>         if (!t_next_contacts()) {
>>             t_reply("408", "Request Timeout MH 2");
>>         } else {
>>             t_on_failure("302");
>>             t_relay();
>>             exit;
>>         }
>>     }
>> }
>>
>> Thanks,
>>
>> Matthew
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20160405/aeb683dc/attachment.html>


More information about the sr-users mailing list