OpenSIPS / opensips

OpenSIPS is a GPL implementation of a multi-functionality SIP Server that targets to deliver a high-level technical solution (performance, security and quality) to be used in professional SIP server platforms.
https://opensips.org
Other
1.26k stars 577 forks source link

Unable to make dispatcher work #2758

Closed 123srikanth closed 2 years ago

123srikanth commented 2 years ago

Hi there,

I'm a beginner to opensips and I want to do load balancing using dispatcher. I want to make the calls come to opensips server from current asterisk server and from opensips I'm trying to dispatch the calls to other two server having FreePBX setup. But here I'm able to get the calls to opensips from current asterisk server but the dispatcher is not able to forward the calls to other servers. In the logs I could see that there are no available destinations coming even after inserting the destinations in dispatcher database. Can you please let me know what change I have to make in the script to make it work.

{ "PARTITIONS": [ { "name": "default", "SETS": [ { "id": 1, "Destinations": [ { "URI": "sip:15.207.211.82:5260", "state": "Probing", "first_hit_counter": 0, "socket": "udp:172.31.10.74:5060" } ] } ] } ] }

#

OpenSIPS loadbalancer script

by OpenSIPS Solutions team@opensips-solutions.com

#

This script was generated via "make menuconfig", from

the "Load Balancer" scenario.

You can enable / disable more features / functionalities by

re-generating the scenario with different options.

#

Please refer to the Core CookBook at:

https://opensips.org/Resources/DocsCookbooks

for a explanation of possible statements, functions and parameters.

#

####### Global Parameters #########

/ uncomment the following lines to enable debugging / debug_mode=yes

debug=3 log_level=3 xlog_level=3 log_stderror=no log_facility=LOG_LOCAL0

udp_workers=4

/ uncomment the next line to enable the auto temporary blacklisting of not available destinations (default disabled) /

disable_dns_blacklist=no

/ uncomment the next line to enable IPv6 lookup after IPv4 dns lookup failures (default disabled) / dns_try_ipv6=yes

socket=udp:172.31.10.74:5060 # CUSTOMIZE ME socket=tcp:172.31.10.74:5060 # CUSTOMIZE ME

####### Modules Section ########

set module path

mpath="/usr/lib/x86_64-linux-gnu/opensips/modules/"

HTTPD module

loadmodule "httpd.so" modparam("httpd", "port", 8888) modparam("httpd","ip","127.0.0.1")

SIGNALING module

loadmodule "signaling.so"

StateLess module

loadmodule "sl.so"

Transaction Module

loadmodule "tm.so" modparam("tm", "fr_timeout", 5) modparam("tm", "fr_inv_timeout", 30) modparam("tm", "restart_fr_on_each_reply", 0) modparam("tm", "onreply_avp_mode", 1)

Record Route Module

loadmodule "rr.so" / do not append from tag to the RR (no need for this script) / modparam("rr", "append_fromtag", 0)

MAX ForWarD module

loadmodule "maxfwd.so"

SIP MSG OPerationS module

loadmodule "sipmsgops.so"

FIFO Management Interface

loadmodule "mi_fifo.so" modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo") modparam("mi_fifo", "fifo_mode", 0666)

MYSQL module

loadmodule "db_mysql.so"

AVPOPS module

loadmodule "avpops.so"

ACCounting module

loadmodule "acc.so" / what special events should be accounted ? / modparam("acc", "early_media", 0) modparam("acc", "report_cancels", 0) / by default we do not adjust the direct of the sequential requests. if you enable this parameter, be sure to enable "append_fromtag" in "rr" module / modparam("acc", "detect_direction", 0) modparam("acc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips") # CUSTOMIZE ME

DISPATCHER module

loadmodule "dispatcher.so" modparam("dispatcher", "db_url", "mysql://opensips:opensipsrw@localhost/opensips") # CUSTOMIZE ME modparam("dispatcher", "ds_ping_method", "INFO") modparam("dispatcher", "ds_ping_maxfwd", 2) modparam("dispatcher", "ds_probing_sock", "udp:192.168.1.100:5077") modparam("dispatcher", "ds_probing_threshhold", 3) modparam("dispatcher", "ds_probing_mode", 1) modparam("dispatcher", "ds_probing_list", "1,2,3") modparam("dispatcher", "options_reply_codes", "501, 403") modparam("dispatcher", "dst_avp", "$avp(ds_dst_failover)") modparam("dispatcher", "grp_avp", "$avp(ds_grp_failover)") modparam("dispatcher", "cnt_avp", "$avp(ds_cnt_failover)") modparam("dispatcher", "sock_avp", "$avp(ds_sock_failover)") modparam("dispatcher", "pvar_algopattern", "$stat(load%u)") modparam("dispatcher", "persistent_state", 1)

modparam("dispatcher", "ds_ping_interval", 30)

additional params added

modparam("dispatcher", "table_name", "dispatcher") modparam("dispatcher", "setid_col", "setid") modparam("dispatcher", "destination_col", "destination") modparam("dispatcher", "state_col", "state") modparam("dispatcher", "weight_col", "weight") modparam("dispatcher", "priority_col", "priority") modparam("dispatcher", "attrs_col", "attrs") modparam("dispatcher", "socket_col", "socket")

MI_HTTP module

loadmodule "mi_http.so"

loadmodule "proto_udp.so"

loadmodule "proto_tcp.so"

####### Routing Logic ########

main request routing logic

route{

if (!mf_process_maxfwd_header(10)) {
    send_reply(483,"Too Many Hops");
    exit;
}

if (has_totag()) {

    # handle hop-by-hop ACK (no routing required)
    #if ( is_method("ACK") && t_check_trans() ) {
    #   t_relay();
    #   exit;
    #}

    # sequential request withing a dialog should
    # take the path determined by record-routing
    if ( !loose_route() ) {
        # we do record-routing for all our traffic, so we should not
        # receive any sequential requests without Route hdr.
        send_reply(404,"Not here");
        exit;
    }

    if (is_method("BYE")) {
        # do accounting even if the transaction fails
        do_accounting("db","failed");

    }

    # route it out to whatever destination was set by loose_route()
    # in $du (destination URI).
    route(RELAY);
    exit;
}

#### INITIAL REQUESTS

# CANCEL processing
if (is_method("CANCEL")) {
    if (t_check_trans())
        t_relay();
    exit;
} else if (!is_method("INVITE")) {
    send_reply(405,"Method Not Allowed");
    exit;
}

if ($rU==NULL) {
    # request with no Username in RURI
    send_reply(484,"Address Incomplete");
    exit;
}

t_check_trans();

# preloaded route checking
if (loose_route()) {
    xlog("L_ERR",
        "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");
    if (!is_method("ACK"))
        send_reply(403,"Preload Route denied");
    exit;
}

# record routing
record_route();

do_accounting("db");

if ( !ds_select_dst(1,4) ) {

    send_reply(500,"No Destination available");
    exit;
}

t_on_failure("GW_FAILOVER");

route(RELAY);

}

route[RELAY] { if (!t_relay()) { sl_reply_error(); } exit; }

failure_route[GW_FAILOVER] { if (t_was_cancelled()) { exit; }

# failure detection with redirect to next available trunk
if (t_check_status("(408)|([56][0-9][0-9])")) {
    xlog("Failed trunk $rd/$du detected \n");

    if ( ds_next_dst() ) {

        t_on_failure("GW_FAILOVER");
        t_relay();
        exit;
    }

    send_reply(500,"All GW are down");
}

}

ovidiusas commented 2 years ago

It seems that your destination is in probing mode. From the documentation: When an address is marked as inactive or probing, it will be ignored by ds_select_dst() and ds_select_domain().

This is not a bug. Please post questions to the mailing list.

123srikanth commented 2 years ago

I'm posting to mailing list but I'm not getting any response since past 2 weeks. can you please tell me what can I do

123srikanth commented 2 years ago

later I have updated the status to active

{ "PARTITIONS": [ { "name": "default", "SETS": [ { "id": 1, "Destinations": [ { "URI": "sip:15.207.211.82", "state": "Active", "first_hit_counter": 0, "socket": "udp:172.31.10.74:5060" } ] } ] } ] }

and the error I'm getting is this Failed trunk 13.235.183.239/ detected Feb 23 07:23:57 ip-172-31-10-74 /usr/sbin/opensips[871]: inside has_totag Feb 23 07:23:57 ip-172-31-10-74 /usr/sbin/opensips[871]: inside is method ACK Feb 23 07:24:12 ip-172-31-10-74 /usr/sbin/opensips[873]: Failed trunk 13.235.183.239/ detected Feb 23 07:24:12 ip-172-31-10-74 /usr/sbin/opensips[871]: inside has_totag Feb 23 07:24:12 ip-172-31-10-74 /usr/sbin/opensips[871]: inside is method ACK

Muhammad-Aqib-Ali commented 6 months ago

"I was also facing a similar type of issue. I found a solution that may be helpful. The issue was that I was unable to add a destination in the dispatcher from the OpenSIPS control panel. Adding a destination directly in the database doesn't work sometimes. The reason is that the code for adding a destination in the dispatcher is not syncing with the control panel version 9.3.4. Although it works fine for the 3.3 version of the control panel. The solution is to open /var/www/html/opensips-cp/web/tools/system/dispatcher/apply_changes.php and update the query as follows:

$sql = "INSERT INTO ".$table." (setid, destination, socket, state, weight, attrs, probe_mode, description) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";

There was a very small mistake where the number of question marks was 7 earlier. It should be 8 for version 9.3.4."