[SR-Users] Manage blacklisting on network errors

Marat Gareev maratkin94 at gmail.com
Tue Oct 12 13:28:38 CEST 2021


Thank you, Bastian.
It solved the problem.

пн, 11 окт. 2021 г. в 21:55, Bastian Triller <bastian.triller at gmail.com>:

> configure xavp_dst like
> modparam("dispatcher", "xavp_dst", "_dsdst_")
> and use $xavp(_dsdst_=>uri) in failure/reply route
>
> On Mon, Oct 11, 2021 at 6:39 PM Marat Gareev <maratkin94 at gmail.com> wrote:
>
>> Hello again,
>>
>> Related question: how to log destination ip/port of dispatcher set from
>> failure_route?
>>
>> $si:$sp works as expected in onreply_route block:
>> onreply_route[MANAGE_REPLY] {
>> xlog("L_NOTICE", "$rr ($rs) [$cs] ($ci) $si:$sp - $ua\n");
>> if ( t_check_status("(503)|(408)|(480)") ) {
>> xlog("L_WARN", "Server will be blacklisted: $si:$sp ($rs)\n");
>> }
>> }
>>
>> I tried to use this example
>> http://www.kamailio.org/wiki/cookbooks/5.2.x/pseudovariables#t_req_pv,
>> but get <null>:
>> failure_route[MANAGE_FAILURE] {
>>
>> if ( !t_check_status("(503)|(408)|(480)") ) {
>> exit;
>> }
>>
>> xlog("L_WARN", "Server will be blacklisted: $T_rpl($si):$T_rpl($sp)\n");
>> ds_mark_dst("IP"); # Set current server to probbing state
>> $si:$sp without T_rpl returns address and port of client.
>>
>> Marat
>>
>> вт, 14 сент. 2021 г. в 14:09, Henning Westerholt <hw at skalatan.de>:
>>
>>> Hello,
>>>
>>>
>>>
>>> regarding your previous question:
>>>
>>> “How can such cases be managed and how can they be logged?”
>>>
>>>
>>>
>>> If you want to log the case that a destination goes offline, as
>>> mentioned have a look to the dispatcher event routes at the bottom of the
>>> docs.
>>>
>>>
>>>
>>> If you have another question, please elaborate. 😊
>>>
>>>
>>>
>>> Cheers,
>>>
>>>
>>>
>>> Henning
>>>
>>>
>>>
>>> --
>>>
>>> Henning Westerholt – https://skalatan.de/blog/
>>>
>>> Kamailio services – https://gilawa.com
>>>
>>>
>>>
>>> *From:* Marat Gareev <maratkin94 at gmail.com>
>>> *Sent:* Tuesday, September 14, 2021 1:02 PM
>>> *To:* Henning Westerholt <hw at skalatan.de>
>>> *Cc:* Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org>
>>> *Subject:* Re: [SR-Users] Manage blacklisting on network errors
>>>
>>>
>>>
>>> Hello,
>>>
>>>
>>>
>>> Thank you for replying, but I don't understand how it will help me.
>>>
>>>
>>>
>>> I already use ds_mark_dst() and know how it works. Problem is that I
>>> can't control network errors with like this:
>>>
>>> if (network_error() || *timeout*()) {
>>>
>>>     xlog("L_WARN", "Server $si:$sp has network problems and will be
>>> blacklisted.\n");
>>>
>>>     ds_mark_dst("IP");
>>>
>>> }
>>>
>>>
>>>
>>> Marat
>>>
>>>
>>>
>>> вт, 14 сент. 2021 г. в 13:33, Henning Westerholt <hw at skalatan.de>:
>>>
>>> Hello,
>>>
>>>
>>>
>>> you probably want to check the dispatcher module docs out for this
>>> ds_mark_dst(..) function. You find also some RPC commands to e.g. inspect
>>> on shell. You can also try the event-routes documented there to log some
>>> info.
>>>
>>>
>>>
>>>
>>> https://kamailio.org/docs/modules/stable/modules/dispatcher.html#dispatcher.f.ds_mark_dst
>>>
>>>
>>>
>>> Cheers,
>>>
>>>
>>>
>>> Henning
>>>
>>>
>>>
>>> --
>>>
>>> Henning Westerholt – https://skalatan.de/blog/
>>>
>>> Kamailio services – https://gilawa.com
>>>
>>>
>>>
>>> *From:* sr-users <sr-users-bounces at lists.kamailio.org> *On Behalf Of *Marat
>>> Gareev
>>> *Sent:* Thursday, September 9, 2021 8:02 PM
>>> *To:* Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org>
>>> *Subject:* [SR-Users] Manage blacklisting on network errors
>>>
>>>
>>>
>>> Hello!
>>>
>>>
>>>
>>> I have a simple config for routing requests with failover and
>>> blacklisting on 408, 480 and 503 codes from servers.
>>>
>>>
>>>
>>> This is a part of config:
>>>
>>> *# Wrapper for relaying requests*
>>>
>>> *route[**RELAY**]* {
>>>
>>>
>>>
>>>   *# the base event routes*
>>>
>>>   t_on_branch("MANAGE_BRANCH");
>>>
>>>   t_on_reply("MANAGE_REPLY");
>>>
>>>   t_on_failure("MANAGE_FAILURE");
>>>
>>>
>>>
>>>   if (!t_relay()) {
>>>
>>>     sl_reply_error();
>>>
>>>   }
>>>
>>>   *exit*;
>>>
>>> }
>>>
>>>
>>>
>>> *# Manage incoming replies*
>>>
>>> *onreply_route[**MANAGE_REPLY**]* {
>>>
>>>   xlog("L_NOTICE", "$rr ($rs) [$cs] ($ci) $si:$sp - $ua\n");
>>>
>>>   if ( t_check_status("(503)|(408)|(480)") ) {
>>>
>>>     xlog("L_WARN", "Server will be blacklisted: $si:$sp ($rs)\n");
>>>
>>>   }
>>>
>>> }
>>>
>>>
>>>
>>> *# Manage failure routing cases*
>>>
>>> *failure_route[**MANAGE_FAILURE**]* {
>>>
>>>
>>>
>>>   if ( !t_check_status("(503)|(408)|(480)") ) {
>>>
>>>     *exit*;
>>>
>>>   }
>>>
>>>
>>>
>>>   ds_mark_dst("IP"); *# blacklist*
>>>
>>>
>>>
>>>   if (t_is_canceled()) *exit*;
>>>
>>>
>>>
>>>   if (!ds_next_domain()) {
>>>
>>>     send_reply("503", "Service Unavailable");
>>>
>>>     *exit*;
>>>
>>>   }
>>>
>>>
>>>
>>>   *route(**RELAY**)*;
>>>
>>> }
>>>
>>>
>>>
>>> If there is a timeout or network error on the server side, it is
>>> blacklisted. How can such cases be managed and how can they be logged?
>>> I didn't find this on the module page:
>>>
>>> https://www.kamailio.org/docs/modules/stable/modules/tm.html
>>>
>>>
>>>
>>> __________________________________________________________
>> Kamailio - Users Mailing List - Non Commercial Discussions
>>   * sr-users at lists.kamailio.org
>> Important: keep the mailing list in the recipients, do not reply only to
>> the sender!
>> Edit mailing list options or unsubscribe:
>>   * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions
>   * sr-users at lists.kamailio.org
> Important: keep the mailing list in the recipients, do not reply only to
> the sender!
> Edit mailing list options or unsubscribe:
>   * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20211012/ebf612e7/attachment.htm>


More information about the sr-users mailing list