So, my final configuration is:

One domain with AWS Route53 same weight configuration: 50% server1 and 50% server2

The user register over the domain.

Two Kamailio Servers with DMQ and DMQ_USRLOC modules configured; 1.2.3.4 first server IP and 5.6.7.8 second server IP

Most important configurations Server1:

listen=udp:1.2.3.4:5060
listen=udp:1.2.3.4:5222

# ---- dmq params ----
modparam("dmq", "server_address", "sip:1.2.3.4")
modparam("dmq", "notification_address", "sip:5.6.7.8")
modparam("dmq", "multi_notify", 0)
modparam("dmq", "num_workers", 4)
modparam("dmq", "ping_interval", 30)

# ---- dmq_usrloc params ----
modparam("dmq_usrloc", "enable", 1)
modparam("dmq_usrloc", "sync", 1)
modparam("dmq_usrloc", "batch_size", 10)
modparam("dmq_usrloc", "batch_usleep", 1000)
modparam("dmq_usrloc", "batch_msg_size", 60000)
modparam("dmq_usrloc", "batch_msg_contacts", 50)
modparam("dmq_usrloc", "usrloc_domain", "location")
modparam("dmq_usrloc", "replicate_socket_info", 0)
modparam("dmq_usrloc", "usrloc_delete", 1)

before the block begin with:

$avp(oexten) = $rU;
        if (!lookup("location")) {

I put

if (!dmq_is_from_node()) {
                if(reg_fetch_contacts("location", "$ru", "contacto")) {
                        if($(ulc(contacto=>socket))) == 0 {
                                rewritehost("5.6.7.8");
                        }
                        route(RELAY);
                }
        }

If the socket value is null (0) means the user is registered on the second Kamailio so send INVITE to second Kamailio

route[AUTH] {
#!ifdef WITH_AUTH

if (dmq_is_from_node()) {
        $ru = $tu;
return;
}

If INVITE comes from other DMQ node don't need authentication but I have to change RURI with To URI because I work in a multidomain setting and I'm  using the does_uri_exist function to know if the request is local or not.

Server2:

listen=udp:5.6.7.8:5060
listen=udp:5.6.7.8:5222

# ---- dmq params ----
modparam("dmq", "server_address", "sip:5.6.7.8")
modparam("dmq", "notification_address", "sip:1.2.3.4")
modparam("dmq", "multi_notify", 0)
modparam("dmq", "num_workers", 4)
modparam("dmq", "ping_interval", 30)

# ---- dmq_usrloc params ----
modparam("dmq_usrloc", "enable", 1)
modparam("dmq_usrloc", "sync", 1)
modparam("dmq_usrloc", "batch_size", 10)
modparam("dmq_usrloc", "batch_usleep", 1000)
modparam("dmq_usrloc", "batch_msg_size", 60000)
modparam("dmq_usrloc", "batch_msg_contacts", 50)
modparam("dmq_usrloc", "usrloc_domain", "location")
modparam("dmq_usrloc", "replicate_socket_info", 0)
modparam("dmq_usrloc", "usrloc_delete", 1)

before the block begin with:

$avp(oexten) = $rU;
        if (!lookup("location")) {

if (!dmq_is_from_node()) {
                if(reg_fetch_contacts("location", "$ru", "contacto")) {
                        if($(ulc(contacto=>socket))) == 0 {
                                rewritehost("1.2.3.4");
                        }
                        route(RELAY);
                }
        }

If the socket value is null (0) means the user is registered on the first Kamailio so send INVITE to first Kamailio

route[AUTH] {
#!ifdef WITH_AUTH

if (dmq_is_from_node()) {
        $ru = $tu;
return;
}

If INVITE comes from other DMQ node don't need authentication but I have to change RURI with To URI because I work in a multidomain setting and I'm  using the does_uri_exist function to know if the request is local or not.

LIMITATIONS:

Regards

---
I'm SoCIaL, MayBe
El 31/07/2021 a las 5:23 a. m., Henning Westerholt escribió:

Great, thanks for the confirmation.

 

Henning

 

From: sr-users <sr-users-bounces@lists.kamailio.org> On Behalf Of Social Boh
Sent: Friday, July 30, 2021 8:36 PM
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: Re: [SR-Users] Access via script to location data in the memory

 

Works!

I can access location data presents only in the memory. Now, next step is using $(ulc(contacto=>socket)) to decide which Kamailio have to process the call.

Thank you

---
I'm SoCIaL, MayBe

El 30/07/2021 a las 11:51 a. m., Henning Westerholt escribió:

Hi,

 

just quickly looked in the registrar code, it uses the standard usrloc functions to get data from memory or database.

 

Maybe just give it a try, I think it should work also in in-memory/dmq mode.

 

Cheers,

 

Henning

 

From: sr-users <sr-users-bounces@lists.kamailio.org> On Behalf Of Social Boh
Sent: Friday, July 30, 2021 6:42 PM
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: Re: [SR-Users] Access via script to location data in the memory

 

Hello,

reg_fetch_contacts use a table (I understood) to looking for data about a user.

I'm using USRLOC module without database.

Regards

 

---
I'm SoCIaL, MayBe

El 30/07/2021 a las 11:18 a. m., Henning Westerholt escribió:

Hello,

 

have you looked to the reg_fetch_contact as already pointed out? Then you can access e.g. the socket with the $ulc PV, see the end of the registrar docs for an example.

 

Cheers,

 

Henning

 

--

Henning Westerholt – https://skalatan.de/blog/

Kamailio services – https://gilawa.com

 

From: sr-users <sr-users-bounces@lists.kamailio.org> On Behalf Of Social Boh
Sent: Friday, July 30, 2021 6:11 PM
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: Re: [SR-Users] Access via script to location data in the memory

 

Hello,

maybe is better I explain what I'd like to achieve:

I have two Kamailio using DMQ and DMQ_USRLOC modules so each REGISTER is replicate on each Kamailio. I'm using DNS weight to distribute the REGISTERs between the 2 Kamailios.

The only difference I have seen in the location data, with kamctl ul show command, is the Kamailio receives REGISTER have socket parameter with transport, ip, y port like udp:1.2.3.4:5060 where 1.2.3.4 is Kamailio public IP; the other Kamailio have this field empty.

When a call arrive to one Kamailio, querying the Socket field I can known if I have to send the INVITE locally or forward the INVITE to second Kamailio.

I don't know if there is other way to achieve this goal.

I think PATH protocol not apply here because If I reply the REGISTER to the second Kamailio adding path header, I don't need DMQ_USRLOC.

The idea is to take advantage of using these DMQ related modules.

Regards

---
I'm SoCIaL, MayBe

El 29/07/2021 a las 5:16 p. m., Henning Westerholt escribió:

Hello,
 
There are different functions in the registrar module, check them out: https://kamailio.org/docs/modules/devel/modules/registrar.html#idm576
 
reg_fetch_contacts(..) might be something you could use.
 
Cheers,
 
Henning