Discussion:
[SR-Users] howto synchronize ruid across multiple proxy instances
Andrew Pogrebennyk
2014-09-12 13:42:29 UTC
Permalink
Hi,
let's say I'm running two proxies/registrars that need to access Shared
location DB in db_mode=1 (all changes to usrloc are immediately
reflected in database too). I have observed that if the UAC re-registers
before the previous registration's expiry and the new REGISTER reaches
the other proxy than the one that processed the registration originally,
this new proxy is going to insert the second record for the same
username into location table instead of updating the existing registration.

I assume the problem is the ruid calculation, because proxy2 generated a
different ruid than proxy1 since internal state of the two nodes is not
shared. I have two questions: 1) is that assumption correct? 2) is there
any way to synchronize the "ruid" of the two nodes in usrloc module,
similar to the "secret" parameter in the auth module, or a better
solution? I prefer the load-balancer to select random proxy and not do a
hash based on From URI.

I don't have the trace of the two registrations at the moment, but could
get one next week. The issue popped up when running some sipp tests, but
it's also possible that some cheap SIP endpoint would register well
before the expiration time, creating duplicate registration. So if
someone dials its number it's going to receive multiple incoming calls.

Here are the module parameters I am using, all quite ordinary:

modparam("usrloc", "use_domain", USE_DOMAIN)
modparam("usrloc", "db_mode", 1)
modparam("usrloc", "db_url", CENTRAL_URL)
modparam("usrloc", "db_check_update", 0)
modparam("usrloc", "nat_bflag", FLB_NATB)

modparam("registrar", "default_expires", 3600)
modparam("registrar", "min_expires", 60)
modparam("registrar", "max_expires", 43200)
modparam("registrar", "method_filtering", 0)
modparam("registrar", "append_branches", 1)
modparam("registrar", "max_contacts", 5)
modparam("registrar", "received_avp", "$avp(s:received)")
modparam("registrar", "use_path", 1)
modparam("registrar", "path_mode", 0)
modparam("registrar", "path_use_received", 1)
modparam("registrar", "gruu_enabled", 0)

Any ideas?

Thanks in advance.
Andrew
Alex Balashov
2014-09-12 13:43:22 UTC
Permalink
Andrew,

Try using db_mode 3 for usrloc.

-- Alex
--
Alex Balashov - Principal
Evariste Systems LLC
Tel: +1-678-954-0670
Web: http://www.evaristesys.com/, http://www.alexbalashov.com/

Please be kind to the English language:

http://www.entrepreneur.com/article/232906
Daniel-Constantin Mierla
2014-09-15 10:04:46 UTC
Permalink
Hello,
Post by Andrew Pogrebennyk
Hi,
let's say I'm running two proxies/registrars that need to access Shared
location DB in db_mode=1 (all changes to usrloc are immediately
reflected in database too). I have observed that if the UAC re-registers
before the previous registration's expiry and the new REGISTER reaches
the other proxy than the one that processed the registration originally,
this new proxy is going to insert the second record for the same
username into location table instead of updating the existing registration.
I assume the problem is the ruid calculation,
if the proxy doesn't have the record in memory, it will not matter if it
is with same ruid or not, it will create a new record. If it is the same
ruid, it will be a failure when inserting in database, not updating it
there, leaving the old record in place.

Also, even if this one will overwrite in database, the other proxy will
still have in memory and will route calls to it.

Alex mentioned in a separate email the db only mode - that could be a
solution.

Also, you can try deleting the record from db via sqlops based on
username, domain, contact uri if the registered() returns false for that
user, before doing save().

If looking at writing C code to get it done, maybe it can be achieved
with a new function to load_db_contacts("userid") to be called before
save().

Back on ruid, just for sake of clarifications, by the way ruid is
generated, is unlikely to get it the same across many systems, because
it uses pid and local counters.

Cheers,
Daniel
Post by Andrew Pogrebennyk
because proxy2 generated a
different ruid than proxy1 since internal state of the two nodes is not
shared. I have two questions: 1) is that assumption correct? 2) is there
any way to synchronize the "ruid" of the two nodes in usrloc module,
similar to the "secret" parameter in the auth module, or a better
solution? I prefer the load-balancer to select random proxy and not do a
hash based on From URI.
I don't have the trace of the two registrations at the moment, but could
get one next week. The issue popped up when running some sipp tests, but
it's also possible that some cheap SIP endpoint would register well
before the expiration time, creating duplicate registration. So if
someone dials its number it's going to receive multiple incoming calls.
modparam("usrloc", "use_domain", USE_DOMAIN)
modparam("usrloc", "db_mode", 1)
modparam("usrloc", "db_url", CENTRAL_URL)
modparam("usrloc", "db_check_update", 0)
modparam("usrloc", "nat_bflag", FLB_NATB)
modparam("registrar", "default_expires", 3600)
modparam("registrar", "min_expires", 60)
modparam("registrar", "max_expires", 43200)
modparam("registrar", "method_filtering", 0)
modparam("registrar", "append_branches", 1)
modparam("registrar", "max_contacts", 5)
modparam("registrar", "received_avp", "$avp(s:received)")
modparam("registrar", "use_path", 1)
modparam("registrar", "path_mode", 0)
modparam("registrar", "path_use_received", 1)
modparam("registrar", "gruu_enabled", 0)
Any ideas?
Thanks in advance.
Andrew
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
Andrew Pogrebennyk
2014-09-18 09:35:17 UTC
Permalink
Hi,
OK, thanks for the clarification. Maybe we will check the
load_db_contacts("userid") way with Victor.

Regards,
Andrew
Post by Daniel-Constantin Mierla
Hello,
Post by Andrew Pogrebennyk
Hi,
let's say I'm running two proxies/registrars that need to access Shared
location DB in db_mode=1 (all changes to usrloc are immediately
reflected in database too). I have observed that if the UAC re-registers
before the previous registration's expiry and the new REGISTER reaches
the other proxy than the one that processed the registration originally,
this new proxy is going to insert the second record for the same
username into location table instead of updating the existing
registration.
I assume the problem is the ruid calculation,
if the proxy doesn't have the record in memory, it will not matter if it
is with same ruid or not, it will create a new record. If it is the same
ruid, it will be a failure when inserting in database, not updating it
there, leaving the old record in place.
Also, even if this one will overwrite in database, the other proxy will
still have in memory and will route calls to it.
Alex mentioned in a separate email the db only mode - that could be a
solution.
Also, you can try deleting the record from db via sqlops based on
username, domain, contact uri if the registered() returns false for that
user, before doing save().
If looking at writing C code to get it done, maybe it can be achieved
with a new function to load_db_contacts("userid") to be called before
save().
Back on ruid, just for sake of clarifications, by the way ruid is
generated, is unlikely to get it the same across many systems, because
it uses pid and local counters.
Cheers,
Daniel
Loading...