<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <tt>Hi Adam,<br>
      <br>
      You can try something like this, it makes sense, considering your
      custom requirements. The local cache is decent as performance, no
      worries. In terms of changing the the destination status from
      script, you can do it only in the context of a call failed to that
      destination. If this is not good for you, let me know and I can
      show you some tricks ;)<br>
      <br>
      Regards,<br>
    </tt>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu
  OpenSIPS Founder and Developer
  <a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a>
</pre>
    <div class="moz-cite-prefix">On 10/31/2017 02:10 PM, Adam Raszynski
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAJWEF2Z7_vwKznUg_ZT-1gpaTNGddXwd_gZ_V3OLX9aPFmxx6A@mail.gmail.com">
      <div dir="ltr">
        <div>
          <div>
            <div>My first idea was to create failure counter for each
              gateway (variable in local cache)<br>
            </div>
            <br>
            Than in onreply route to increment counter every time call
            is not established, and reset counter if any call was
            successful. So we get consecutive failures counter in cache
            and can make further decisions basing on that information<br>
            <br>
          </div>
          Does it make sense? Is local cache fast enough (and causes no
          locking problems) to be incremented in such intensive way?<br>
          <br>
        </div>
        Is it possible to change dispatcher gateway status from inside
        script? Or it's possible only by using external interface?<br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">2017-10-31 12:31 GMT+01:00
          Bogdan-Andrei Iancu <span dir="ltr"><<a
              href="mailto:bogdan@opensips.org" target="_blank"
              moz-do-not-send="true">bogdan@opensips.org</a>></span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> <tt>Hi Adam,<br>
                <br>
                Maybe such a custom logic is outside OpenSIPS scope -
                still have you considered using the ds_set_state MI
                function to control from outside the status of the
                destinations ? Of course you will have to use the Event
                Interface too, to receive the notifications on the
                destination status (when OpenSIPS is doing the state
                transition) - see the E_DISPATCHER_STATUS event
                (<a class="m_-7260080349264954538moz-txt-link-freetext"
href="http://www.opensips.org/html/docs/modules/2.3.x/dispatcher.html#idp5746368"
                  target="_blank" moz-do-not-send="true">http://www.opensips.org/html/<wbr>docs/modules/2.3.x/dispatcher.<wbr>html#idp5746368</a>)<br>
                <br>
                So, when OpenSIPS switches a destination into probing
                (based on a failure detection), you can get the event
                and force the destination into Inactive ; after some
                custom amount of time, you can put it back into Probing
                mode, to allow OpenSIPS to re-enable it.<br>
                <br>
                Regards,<br>
              </tt>
              <pre class="m_-7260080349264954538moz-signature" cols="72">Bogdan-Andrei Iancu
  OpenSIPS Founder and Developer
  <a class="m_-7260080349264954538moz-txt-link-freetext" href="http://www.opensips-solutions.com" target="_blank" moz-do-not-send="true">http://www.opensips-solutions.<wbr>com</a>
</pre>
              <div>
                <div class="h5">
                  <div class="m_-7260080349264954538moz-cite-prefix">On
                    10/28/2017 04:13 PM, Adam Raszynski wrote:<br>
                  </div>
                </div>
              </div>
              <blockquote type="cite">
                <div>
                  <div class="h5">
                    <div dir="ltr">
                      <div>
                        <div>
                          <div>
                            <div>
                              <div>Hi<br>
                                <br>
                              </div>
                              Could you suggest some working
                              configuration of the dispatcher module for
                              the following setup:<br>
                              <br>
                            </div>
                            - Flag gateway as failed (even if it's still
                            responding to OPTIONS) after some number of
                            consecutive call failures. That's the easy
                            part<br>
                          </div>
                          <br>
                          - Automatically un-flag gateway after some
                          time, to allow re-checking (reset failure
                          counter?)<br>
                          <br>
                        </div>
                        - Ideal solution would also include increasing
                        re-check interval, ie first re-check after 1
                        minute, if next failure detected next re-check
                        after 2 minutes, next after 4 and so on<br>
                        <br>
                        <br>
                      </div>
                      Best Regards<br>
                      <br>
                    </div>
                    <br>
                    <fieldset
                      class="m_-7260080349264954538mimeAttachmentHeader"></fieldset>
                    <br>
                  </div>
                </div>
                <pre>______________________________<wbr>_________________
Users mailing list
<a class="m_-7260080349264954538moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org" target="_blank" moz-do-not-send="true">Users@lists.opensips.org</a>
<a class="m_-7260080349264954538moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank" moz-do-not-send="true">http://lists.opensips.org/cgi-<wbr>bin/mailman/listinfo/users</a>
</pre>
              </blockquote>
              <br>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>