<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Good time!   <br>
    <br>
    Sometimes, the subscriber receives a "503", "Simultaneous calls
    limit reached".<br>
    I guess it's because of the incorrectness of the dialogue.<br>
    It helps to restart Opensips<br>
    It is necessary to determine the cause of non-completion of
    dialogue.<br>
    I think they need to use for this database, but how to do it?<br>
    And how to identify and remove the cause with the help of the
    database?<br>
    Thanks!<br>
    <br>
    <br>
    part of the CFG below:<br>
    <br>
    #### Dialog Module<br>
    loadmodule "dialog.so"<br>
    modparam("dialog", "db_url",
    "mysql://opensips:opensipsrw@localhost/opensips")<br>
    modparam("dialog", "table_name", "dialog")<br>
    modparam("dialog", "db_mode", 1)<br>
    modparam("dialog", "db_update_period", 60)<br>
    modparam("dialog", "profiles_with_value", "gwquota;subscriberquota")<br>
    <br>
    modparam("auth_db", "load_credentials",
    "$avp(subscriber_username)=username")<br>
    <br>
    route[subscriberquota] {<br>
    <br>
        avp_db_query("select quota from subscriber where
    username='$var(subscriber)'","$avp(subscriberquota)");<br>
        if ($avp(subscriberquota) == 0) {<br>
            xlog("Subscriberquota route, NO LIMIT FOR USER
    &lt;$var(subscriber)&gt;");<br>
            return;<br>
        }<br>
        $var(size) = 0;<br>
        get_profile_size("subscriberquota", "$var(subscriber)",
    "$var(size)");<br>
        if( $var(size) &gt;= $avp(subscriberquota) ){<br>
            sl_send_reply("503", "Simultaneous calls limit reached");<br>
            xlog("Subscriberquota route, Limit of $var(size) active
    calls has been reached for subscriber $var(subscriber)");<br>
            exit;<br>
        }<br>
        set_dlg_profile("subscriberquota","$var(subscriber)");<br>
        get_profile_size("subscriberquota", "$var(subscriber)",
    "$var(size)");<br>
        xlog("Subscriberquota route, there are now $var(size) active
    calls for subscriber $var(subscriber)");<br>
        return;<br>
    <br>
    }<br>
    <br>
    route[gwquota] {<br>
    <br>
        #avp_db_query("select quota from quota where
    username='$avp(gw_id)'","$avp(gwquota)");<br>
        if ($avp(gw_attrs) == 0) {<br>
            xlog("GWquota route, NO LIMIT FOR GW $avp(gw_id)");<br>
            return;<br>
        }<br>
        $avp(gwquota) = $avp(gw_attrs);<br>
        $var(size) = 0;<br>
        get_profile_size("gwquota", "$avp(gw_id)", "$var(size)");<br>
        if( $var(size) &gt;= $avp(gwquota) ){<br>
            sl_send_reply("503", "Simultaneous calls limit reached");<br>
            xlog("GWquota route, Limit of $var(size) active calls has
    been reached for GW $avp(gw_id)");<br>
            exit;<br>
        }<br>
        set_dlg_profile("gwquota","$avp(gw_id)");<br>
        get_profile_size("gwquota", "$avp(gw_id)", "$var(size)");<br>
        xlog("GWquota route, there are now $var(size) active calls for
    GW $avp(gw_id)");<br>
        return;<br>
    <br>
    }<br>
    <br>
    <div>route[dialog] {</div>
    <div><br>
    </div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>if
      (has_totag()) {</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>#
      sequential requests within a dialog should</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>#
      take the path determined by record-routing</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>if
      (loose_route()) {</div>
    <div><br>
    </div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>if
      (method=="BYE" || method=="CANCEL") {</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>setflag(ACC_DO);
      # do accounting ...</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>setflag(ACC_FAILED);
      # ... even if the transaction fails</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>}
      else if (is_method("INVITE")) {</div>
    <div>                # even if in most of the cases is useless, do
      RR for</div>
    <div>                # re-INVITEs alos, as some buggy clients do
      change route set</div>
    <div>                # during the dialog.</div>
    <div>                record_route();</div>
    <div>            }</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>#
      route it out to whatever destination was set by loose_route()</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>#
      in $du (destination URI).</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>route(relay);</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>}
      else {</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>if
      ( is_method("ACK") ) {</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>if
      ( t_check_trans() ) {</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>t_relay();</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>exit;</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>}
      else {</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>#
      ACK without matching transaction -&gt;</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>#
      ignore and discard</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>exit;</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>sl_send_reply("404","Not
      here");</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>exit;</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
    <div><br>
    </div>
    <div>}</div>
    <div><br>
    </div>
    <div>route[invite] {</div>
    <div><br>
    </div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>#
      account only INVITEs</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>if
      (is_method("INVITE")) {</div>
    <div>        create_dialog("B");</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>xlog("L_INFO",
      "New invite recived\n");</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>perl_exec("test");</div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>xlog("L_INFO",
      "Execution perl function result is $retcode\n");</div>
    <div>        if (is_from_gw("0","i","$avp(gw_attrs)")) {</div>
    <div>            route(gwquota);</div>
    <div>            route(terminate);</div>
    <div>        } else {</div>
    <div>            route(auth);</div>
    <div>            $DLG_timeout=60;</div>
    <div>            $var(subscriber) = $avp(subscriber_username);</div>
    <div>            route(subscriberquota);</div>
    <div>            route(originate);</div>
    <div>        }</div>
    <div><br>
    </div>
    <div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
    <div><br>
    </div>
    <div>}</div>
    <br>
  </body>
</html>