[OpenSIPS-Users] cluster configuration for dialogs

Alberto alberto.rinaudo at gmail.com
Tue May 2 23:00:09 UTC 2023


Hi,
do you ever get the feeling you are going nuts? Anyways...
I have 2 opensips servers, both version 3.2.12, on debian 11
they both share the same configuration, and start opensips using m4 as
follows: `opensips -F -f /etc/opensips/opensips.cfg -p "m4
/etc/opensips/env.m4 -"`


m4 server1:divert(-1)
define(`M4_LAN_IP', `10.0.0.124')
define(`M4_WAN_IP', `10.0.0.124')
define(`M4_CLUSTER_NODE_ID', `1')
define(`M4_SHARING_TAG', `node_1')
define(`M4_CLUSTER_ID', `1')
divert(0)dnl


m4 server 2:divert(-1)
define(`M4_LAN_IP', `10.0.0.125')
define(`M4_WAN_IP', `10.0.0.125')
define(`M4_CLUSTER_NODE_ID', `2')
define(`M4_SHARING_TAG', `node_2')
define(`M4_CLUSTER_ID', `1')
divert(0)dnl


configuration:
debug_mode=no

log_level=2
xlog_level=2
log_stdout=yes
log_stderror=yes
log_facility=LOG_LOCAL0

auto_aliases=no

server_signature=yes

socket=udp:0.0.0.0:5060 as M4_WAN_IP:5060
socket=tcp:0.0.0.0:5060 as M4_WAN_IP:5060
socket=tls:0.0.0.0:5061 as M4_WAN_IP:5061
socket=bin:0.0.0.0:5555 as M4_WAN_IP:5555

tcp_connect_timeout=300

mpath="/usr/lib64/opensips/modules/"

loadmodule "tls_openssl.so"

loadmodule "tls_mgm.so"
modparam("tls_mgm", "tls_library", "openssl")

modparam("tls_mgm", "server_domain", "sd_1")
modparam("tls_mgm", "ca_list", "[sd_1]/opt/letsencrypt/fullchain.pem")
modparam("tls_mgm", "ca_dir", "[sd_1]/etc/ssl/certs")
modparam("tls_mgm", "certificate", "[sd_1]/opt/letsencrypt/cert.pem")
modparam("tls_mgm", "private_key", "[sd_1]/opt/letsencrypt/privkey.pem")
modparam("tls_mgm", "require_cert", "[sd_1]0")
modparam("tls_mgm", "tls_method", "[sd_1]TLSv1-")
modparam("tls_mgm", "verify_cert", "[sd_1]0")
modparam("tls_mgm", "ec_curve", "[sd_1]secp521r1")

modparam("tls_mgm", "client_domain", "cd_1")
modparam("tls_mgm", "ca_list", "[cd_1]/opt/letsencrypt/fullchain.pem")
modparam("tls_mgm", "ca_dir", "[cd_1]/etc/ssl/certs")
modparam("tls_mgm", "certificate", "[cd_1]/opt/letsencrypt/cert.pem")
modparam("tls_mgm", "private_key", "[cd_1]/opt/letsencrypt/privkey.pem")
modparam("tls_mgm", "require_cert", "[cd_1]0")
modparam("tls_mgm", "tls_method", "[cd_1]TLSv1-")
modparam("tls_mgm", "verify_cert", "[cd_1]0")
modparam("tls_mgm", "ec_curve", "[cd_1]secp521r1")
modparam("tls_mgm", "match_sip_domain", "[cd_1]*")
modparam("tls_mgm", "match_ip_address", "[cd_1]*")

loadmodule "cachedb_mongodb.so"

loadmodule "db_mysql.so"
modparam("db_mysql", "exec_query_threshold", 0)
modparam("db_mysql", "timeout_interval", 5)
modparam("db_mysql", "max_db_queries", 5)
modparam("db_mysql", "max_db_retries", 5)

loadmodule "clusterer.so"
modparam("clusterer", "db_url", "mysql://opensips:opensipsrw@localhost
/opensips")
modparam("clusterer", "my_node_id", M4_CLUSTER_NODE_ID)
modparam("clusterer", "seed_fallback_interval", 5)
modparam("clusterer", "sharing_tag", "M4_SHARING_TAG/M4_CLUSTER_ID=active")

loadmodule "signaling.so"

loadmodule "sl.so"

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

loadmodule "rr.so"
modparam("rr", "append_fromtag", 1)

loadmodule "dialog.so"
modparam("dialog", "cachedb_url", "mongodb://
10.0.0.120:27017/opensipsDB.dialog")
modparam("dialog", "default_timeout", 14400) # 4 hours
modparam("dialog", "dialog_replication_cluster", M4_CLUSTER_ID)
modparam("dialog", "dlg_match_mode", 1)
modparam("dialog", "enable_stats", 1)
modparam("dialog", "profile_replication_cluster", M4_CLUSTER_ID)
modparam("dialog", "profiles_no_value", "shared/s")
modparam("dialog", "profiles_with_value", "caller")

loadmodule "topology_hiding.so"
modparam("topology_hiding", "force_dialog", 1)

loadmodule "uac.so"
modparam("uac", "restore_mode", "auto")
modparam("uac", "force_dialog", yes)

loadmodule "permissions.so"
modparam("permissions", "db_url", "mysql://opensips:opensipsrw@localhost
/opensips")

loadmodule "sipmsgops.so"

loadmodule "textops.so"

loadmodule "callops.so"

loadmodule "usrloc.so"
modparam("usrloc", "cachedb_url", "mongodb://
10.0.0.120:27017/opensipsDB.usrloc")
modparam("usrloc", "location_cluster", M4_CLUSTER_ID)
modparam("usrloc", "nat_bflag", "NAT")
modparam("usrloc", "use_domain", 1)
modparam("usrloc", "working_mode_preset", "federation-cachedb-cluster")

loadmodule "registrar.so"
modparam("registrar", "max_contacts", 1)
modparam("registrar", "tcp_persistent_flag", "TCP_PERSIST_DURATION")

loadmodule "mid_registrar.so"
modparam("mid_registrar", "max_contacts", 1)
modparam("mid_registrar", "mode", 0)
modparam("mid_registrar", "tcp_persistent_flag",
"TCP_PERSIST_REGISTRATIONS")

loadmodule "proto_bin.so"

loadmodule "proto_udp.so"

loadmodule "proto_tcp.so"

loadmodule "proto_tls.so"

route {
  if (has_totag()) {
    if (topology_hiding_match("DID_FALLBACK")) {
    } else if (loose_route()) {
      if ($DLG_status != NULL && !validate_dialog()) {
        exit;
      }
    } else {
      if (is_method("ACK")) {
        if (t_check_trans()) {
          t_relay();
        }
        exit;
      }

      sl_send_reply(404, "Not Found");
      exit;
    }

    t_relay();

    exit;
  }

  if (is_method("CANCEL")) {
    if (t_check_trans()) {
      t_relay();
    }
    exit;
  }

  t_check_trans();

  if (is_myself($si)) {
    sl_send_reply(406, "Not Acceptable");
    exit;
  }

  if (is_method("REGISTER")) {
    mid_registrar_save("location", "p0", , , "M4_SHARING_TAG");
    switch ($retcode) {
      case 1:
        $ru = "sip:sip.test.com";
        t_relay();
        break;
      case 2:
        break;
      default:
        break;
    }

    exit;
  }

  if ($rU == NULL) {
    sl_send_reply(484, "Address Incomplete");
    exit;
  }


  if (is_method("INVITE")) {
    if (!create_dialog("B")) {
      sl_send_reply(500, "Internal Server Error");
      exit;
    }

    if (is_registered("location")) {
      $ru = "sip:" + $tU + "@sip.test.com";
    } else {
      t_reply(404, "Not Found");
      exit;
    }

    topology_hiding("UC");

    t_reply(100, "Giving it a try");

    set_dlg_sharing_tag("M4_SHARING_TAG");
    set_dlg_profile("shared");
  }

  route(relay);
}

route[relay] {
  if (!t_relay()) {
    sl_send_reply(500, "Internal Error");
  }

  exit;
}


With this configuration I can make a sip client register, and make calls,
and I also get the usrloc collection in mongodb.

But why isn't the dialog collection created??

If I do the following commands: `opensips-cli -x mi clusterer_list`
`opensips-cli -x mi clusterer_list_topology` `opensips-cli -x mi
clusterer_list_shtags` `opensips-cli -x mi dlg_list`
I can see the clusterer is setup correctly, the nodes are there, the tags
are there as active/backup, and they are both aware of the dialog. So they
are sharing it over the bin interface, but why is it not saved in mongodb??

Follow up problem that's making me nuts: let's say call starts on the
second server, so it's tagged as `node_2`
if I go on the first server and do `opensips-cli -x mi
clusterer_shtag_set_active node_2/1` it makes the tag active on the first
server and I can then `clusterer_list_shtags` and see that the tag has
become active on the first node and backup on the second node, but nothing
else happens.
Shouldn't the call be re-homed with a reinvite or an update??
If I try to re-home it manually on the first server with `opensips-cli -x
mi dlg_send_sequential callid=afb2fe39aec0470f9cd3a010239f8aca
mode=challenge body=outbound` it fails with 408 timeout.

What am I missing???

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20230503/6d41ae8b/attachment.html>


More information about the Users mailing list