[OpenSIPS-Users] t_reply() with Reason header

Bogdan-Andrei Iancu bogdan at opensips.org
Fri Apr 16 12:09:00 EST 2021


try via $(<reply>hdr(Reason)) in failure route, but be sure that the 402 
is the winning reply, triggering the failover route.

Regards,

Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
   https://www.opensips-solutions.com
OpenSIPS Bootcamp 2021 online
   https://opensips.org/training/OpenSIPS_eBootcamp_2021/

On 4/16/21 2:59 PM, solarmon wrote:
> Hi Bogdan,
>
> It is in the response coming back to us from the dispatcher endpoint. 
> In this case, it is an 402 Bad Gateway message, which has a Reason 
> header with the cause code in it.
>
> On Fri, 16 Apr 2021 at 12:43, Bogdan-Andrei Iancu <bogdan at opensips.org 
> <mailto:bogdan at opensips.org>> wrote:
>
>     Where do you want to extract the Reason from (like sip msg) ?
>
>     Regards,
>
>     Bogdan-Andrei Iancu
>
>     OpenSIPS Founder and Developer
>        https://www.opensips-solutions.com
>     OpenSIPS Bootcamp 2021 online
>        https://opensips.org/training/OpenSIPS_eBootcamp_2021/
>
>     On 4/16/21 1:28 PM, solarmon wrote:
>>     Hi Bogdan,
>>
>>     Thanks for the response amd link to append_to_reply()
>>
>>     What is the best function to use to extract the Reason header to
>>     feed in to append_to_reply()?
>>
>>     Thank you.
>>
>>     On Fri, 16 Apr 2021 at 11:07, Bogdan-Andrei Iancu
>>     <bogdan at opensips.org <mailto:bogdan at opensips.org>> wrote:
>>
>>         Hi,
>>
>>         use the append_to_reply() function
>>
>>         https://opensips.org/html/docs/modules/3.1.x/sipmsgops.html#func_append_to_reply
>>
>>         Regards,
>>
>>         Bogdan-Andrei Iancu
>>
>>         OpenSIPS Founder and Developer
>>            https://www.opensips-solutions.com
>>         OpenSIPS Bootcamp 2021 online
>>            https://opensips.org/training/OpenSIPS_eBootcamp_2021/
>>
>>         On 4/16/21 12:22 PM, solarmon wrote:
>>>         Hi,
>>>
>>>         We have a code that response back with a "503 Service not
>>>         available" if it has exhausted all the dispatcher endpoints
>>>         - see end of email.
>>>
>>>         It would be useful if we casn send back the Reason header of
>>>         the last rejection. Could this be done and what should I
>>>         look at?
>>>
>>>         Thank you!
>>>
>>>         failure_route[call_failover]
>>>         {
>>>                 xlog("[$ci] call failed to established with
>>>         $T_reply_code code\n");
>>>
>>>                 rtpproxy_unforce("$avp(rtpp_set)");
>>>
>>>                 if (t_was_cancelled()) {
>>>                         t_reply("487","Request cancelled");
>>>                         exit;
>>>                 }
>>>
>>>                 # any failure indication ?
>>>                 if ( t_check_status("[56][0-9][0-9]")
>>>                 || (t_check_status("408") && t_local_replied("all"))
>>>                 ) {
>>>                         xlog("[$ci] destination $rd failed  with
>>>         $T_reply_code -> retry\n ");
>>>
>>>                         ###ds_mark_dst("p");
>>>
>>>                         if ( ds_next_domain() ) {
>>>                                 xlog("[$ci] using new destination
>>>         <$rd>\n ");
>>>
>>>                                 # send it out again
>>>         t_on_failure("call_failover");
>>>                                 t_relay();
>>>                                 exit;
>>>                         } else {
>>>                                 xlog("[$ci] no other destination to
>>>         retry\n ");
>>>                                 t_reply("503","Service not available");
>>>                                 exit;
>>>                         }
>>>                 }
>>>
>>>                 # if call failure, allow the reply to propagate to
>>>         caller
>>>                 exit;
>>>         }
>>>
>>>         _______________________________________________
>>>         Users mailing list
>>>         Users at lists.opensips.org  <mailto:Users at lists.opensips.org>
>>>         http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20210416/db811c4b/attachment.html>


More information about the Users mailing list