[Users] Error when trying to lookup locations in a non local database

Klaus Darilion klaus.mailinglists at pernau.at
Fri Feb 24 14:31:54 CET 2006


Hi!

(open)ser's usually lookup the location only from the memory. No 
database lookup is involved. Bugdan submitted a new feature to openser 
CVS head on 22.2.06, which introduces the new behaviour to always lookup 
the in the database.
http://cvs.sourceforge.net/viewcvs.py/openser/sip-server/modules/usrloc/README?r1=1.4&r2=1.5

But beware, this feature might decrease the performance of your 
installation, especially when using NAT-pings.

You could also use t_replicate() to replicate the REGISTER messages 
between the SIP proxies. But AFAIK this supports only registration 
between 2 proxies.

regards
klaus

Dioris Moreno wrote:
> I have three sip proxies configured with OpenSER and MediaProxy for NAT
> traversal support, I'm going to call them Proxy A, B and C. These
> proxies work together as a farm; the Proxies A and C points to the MySql
> database installed in Proxy B. Proxy B serves as location server an also
> as proxy. Everything works fine, the REGISTER requests are validated
> against the database (installed in Proxy B) by any proxy without any
> problem. Also, the location records are inserted without any problem.
> However, I noticed when Proxies A or C receive an INVITE request, they
> respond 404 - User Not Found. I made a lot of debug, captures and
> anything else, and I found the lookup function is only getting locations
> for user agents registered by the Proxy that is making the query; in
> other words, if the user X registers through Proxy A, then an INVITE
> request received by Proxy A to user X is routed successfully.
> 
> I don't know if I'm missing something. I'm using db_mode 1 for usrloc to
> store locations directly in the database. Below is one of my
> configuration scripts, the three are practically the same, they are
> different on the listen IP addresses and in the record route for nated
> clients.
> 
> I'll appreciate any help. Thank you
> 
> # ----------- global configuration parameters ------------------------
> debug=9            # debug level (cmd line: -dddddddddd)
> fork=yes
> log_stderror=no    # (cmd line: -E)
> # Uncomment these lines to enter debugging mode 
> #fork=no
> #log_stderror=yes
> #
> check_via=no      # (cmd. line: -v)
> dns=no          # (cmd. line: -r)
> rev_dns=no      # (cmd. line: -R)
> listen=AAA.BBB.CCC.DDD
> port=5060
> children=4
> fifo="/tmp/openser_fifo"
> fifo_db_url="mysql://openser:password@dbs.sip.mydomain.com/openser"
> #Aliases
> alias="sip.mydomain.com"
> # ------------------ module loading ----------------------------------
> loadmodule "/usr/local/lib/openser/modules/mysql.so"
> loadmodule "/usr/local/lib/openser/modules/sl.so"
> loadmodule "/usr/local/lib/openser/modules/tm.so"
> loadmodule "/usr/local/lib/openser/modules/rr.so"
> loadmodule "/usr/local/lib/openser/modules/maxfwd.so"
> loadmodule "/usr/local/lib/openser/modules/usrloc.so"
> loadmodule "/usr/local/lib/openser/modules/registrar.so"
> loadmodule "/usr/local/lib/openser/modules/auth.so"
> loadmodule "/usr/local/lib/openser/modules/auth_db.so"
> loadmodule "/usr/local/lib/openser/modules/alias_db.so"
> loadmodule "/usr/local/lib/openser/modules/uri.so"
> loadmodule "/usr/local/lib/openser/modules/uri_db.so"
> loadmodule "/usr/local/lib/openser/modules/domain.so"
> loadmodule "/usr/local/lib/openser/modules/mediaproxy.so"
> loadmodule "/usr/local/lib/openser/modules/nathelper.so"
> loadmodule "/usr/local/lib/openser/modules/textops.so"
> loadmodule "/usr/local/lib/openser/modules/xlog.so"
> # ----------------- setting module-specific parameters ---------------
> modparam("usrloc|auth_db|domain|uri_db|alias_db", "db_url",
> "mysql://openser:password@dbs.sip.mydomain.com/openser")
> modparam("usrloc", "use_domain", 0)
> modparam("usrloc", "db_mode", 1)
> modparam("usrloc", "timer_interval", 60)
> modparam("registrar", "use_domain", 0)
> modparam("registrar", "nat_flag", 6)
> modparam("registrar", "min_expires", 10)
> modparam("registrar", "max_expires", 80)
> modparam("registrar", "default_expires", 30)
> modparam("rr", "enable_full_lr", 1)
> modparam("auth_db", "calculate_ha1", yes)
> modparam("auth_db", "password_column", "password") modparam("nathelper",
> "rtpproxy_disable", 1) modparam("nathelper", "natping_interval", 0)
> modparam("mediaproxy","natping_interval", 30)
> modparam("mediaproxy","mediaproxy_socket",
> "/var/run/proxydispatcher.sock")
> modparam("mediaproxy","sip_asymmetrics","/usr/local/etc/openser/sip-clie
> nts")
> modparam("mediaproxy","rtp_asymmetrics","/usr/local/etc/openser/rtp-clie
> nts")
> # -------------------------  request routing logic ------------------- #
> main routing logic route {
>       #
> -----------------------------------------------------------------
>       # Sanity Check Section
>       #
> -----------------------------------------------------------------
>       if (!mf_process_maxfwd_header("10")) {
>             sl_send_reply("483", "Too Many Hops");
>             exit;
>       };
>       if (msg:len > max_len) {
>             sl_send_reply("513", "Message Overflow");
>             exit;
>       };
>       #
> -----------------------------------------------------------------
>       # Record Route Section
>       #
> -----------------------------------------------------------------
>       if (method=="INVITE" && client_nat_test("3")) {
>             record_route_preset("AAA.BBB.CCC.DDD:5060;nat=yes"); 
>       } else if (method!="REGISTER") {
>             record_route(); 
>       };
>       #
> -----------------------------------------------------------------
>       # Call Tear Down Section
>       #
> -----------------------------------------------------------------
>       if (method=="BYE" || method=="CANCEL") {
>             end_media_session();
>       };
>       #
> -----------------------------------------------------------------
>       # Loose Route Section
>       #
> -----------------------------------------------------------------
>       if (loose_route()) {
>             if (has_totag() && (method=="INVITE" || method=="ACK")) {
>                   if (client_nat_test("3") ||
> search("^Route:.*;nat=yes")) {
>                         setflag(6);
>                         use_media_proxy();
>                   };
>             };
>             route(1);
>             exit;
>       };
>       #
> -----------------------------------------------------------------
>       # Call Type Processing Section
>       #
> -----------------------------------------------------------------
>       if (uri!=myself) {
>             route(4);
>             route(1);
>             exit;
>       };
>       if (method=="CANCEL") {
>             route(1);
>             exit;
>       } else if (method=="INVITE") {
>             route(3);
>             exit;
>       } else if (method=="REGISTER") {
>             route(2);
>             exit;
>       } else if (method=="ACK") {
>             exit;
>       };
>       if (uri!=myself) {
>             route(4);
>             route(1);
>             exit;
>       };
>       if (!lookup("location")) {
>             sl_send_reply("404", "User Not Found");
>             exit;
>       };
>       route(1);
> }
> route[1] {
>       #
> -----------------------------------------------------------------
>       # Default Message Handler
>       #
> -----------------------------------------------------------------
>       t_on_reply("1");
>       if (!t_relay()) {
>             if (method=="INVITE" || method=="ACK") {
>                   end_media_session();
>             };
>             sl_reply_error();
>       };
> }
> route[2] {
>       #
> -----------------------------------------------------------------
>       # REGISTER Message Handler
>       # ----------------------------------------------------------------
>       xlog("L_INFO", "REGISTER - entering section\n");
>       if (client_nat_test("7")) {
>             setflag(6);
>             fix_nated_register();
>             force_rport();
>             xlog("L_INFO", "REGISTER - nated client detected and fixed
> ($tu)\n");
>       };
>       if (registered("location")) {
>             xlog("L_INFO", "REGISTER - user already registered
> ($tu)\n");    
>       };
>       if (!www_authorize("sip.mydomain.com","subscriber")) {
>             www_challenge("sip.mydomain.com","0");
>             exit;
>       };
>       if (!check_to()) {
>             xlog("L_WARN", "REGISTER - unauthorized client ($tu)\n");
>             sl_send_reply("401", "Unauthorized");
>             exit;
>       };
>       consume_credentials();
>       xlog("L_INFO", "REGISTER - client authorized ($tu)\n");
>       if (!save("location")) {
>             xlog("L_WARN", "REGISTER - client location could not be
> saved ($tu)\n");
>             sl_reply_error();
>       };
>       xlog("L_INFO", "REGISTER - client location saved ($tu)\n"); }
> route[3] {
>       #
> -----------------------------------------------------------------
>       # INVITE Message Handler
>       #
> -----------------------------------------------------------------
>       xlog("L_INFO", "INVITE - entering section\n");
>       #if (client_nat_test("3")) {
>       if (client_nat_test("7")) {
>             setflag(7);
>             fix_nated_contact();
>             force_rport();
>       };
>       if (!proxy_authorize("sip.mydomain.com","subscriber")) {
>             proxy_challenge("sip.mydomain.com","0");
>             exit;
>       } else if (!check_from()) {
>             sl_send_reply("403", "Use From=ID");
>             exit;
>       };
>       consume_credentials();
>       xlog("L_INFO", "INVITE - proxy authorized\n");
>       if (uri!=myself) {
>             xlog("L_INFO", "INVITE - <$ru> uri is not from here, routing
> out\n");
>             route(4);
>             route(1);
>             exit;
>       };
>       xlog("L_INFO", "INVITE - before aliases lookup <$ru>\n");
>       alias_db_lookup("dbaliases");
>       xlog("L_INFO", "INVITE - after aliases lookup <$ru>\n");
>       if (registered("location")) {
>             xlog("L_INFO", "INVITE - the user is already registered
> <$ru>\n");
>       };
>       if (!lookup("location")) {
>             xlog("L_WARN", "INVITE - not located <$ru>\n");
>             sl_send_reply("404", "User Not Found");
>             exit;
>       };
>       route(4);
>       route(1);
> }
> route[4] {
>       #
> -----------------------------------------------------------------
>       # NAT Traversal Section
>       #
> -----------------------------------------------------------------
>       if (isflagset(6) || isflagset(7)) {
>             xlog("L_INFO", "NAT Traversal - using media proxy\n");
>             use_media_proxy();
>       };
> }
> onreply_route[1] {
>       if ((isflagset(6) || isflagset(7)) &&
> (status=~"(180)|(183)|2[0-9][0-9]")) {
>             if (!search("^Content-Length:[ ]*0")) {
>                   use_media_proxy();
>             };
>       };
>       if (client_nat_test("1")) {
>             fix_nated_contact();
>       };
> }
> 
> 
> _______________________________________________
> Users mailing list
> Users at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/users





More information about the Users mailing list