[OpenSIPS-Users] Registrar's lookup() function not returning contact with greatest q-value
Bogdan-Andrei Iancu
bogdan at voice-system.ro
Wed Aug 4 19:10:53 CEST 2010
Hi Pauba,
First if you want to get only one contact (even if multiple registered),
see the "b" flag of the lookup() function:
http://www.opensips.org/html/docs/modules/1.6.x/registrar.html#id271036
Also if more than one contact is returned, they are ordered of their
value (highest to lowest).
Regards,
Bogdan
Pauba, Kevin L wrote:
> Hi,
>
> According to the registrar documentation module, "... the RURI will be overwritten with the highest-q rated contact ..." when the lookup() function is called. My testing shows that the first matching contact is used.
>
> I'm running OpenSIPS V1.6.2. I should mention that I've written a "heartbeat" module that pings the registered contacts periodically and accepts a "load" value in the response that is used to calculate the q-value. A few bits in the Cflags are used to keep track of those that respond back and I've modified the show command to report the meaning of the flags.
>
> Here's the snippet from the output of the "opensipsctl ul show":
>
> AOR:: hmp
> Contact:: sip:sip at 10.27.193.121 Q=0
> Expires:: 5051
> Callid:: 1 at 10.27.193.121
> Cseq:: 78
> User-agent:: oSIP/wicsip-2.11.MR3519
> State:: CS_NEW
> Flags:: 1
> Cflag:: 34 (hb enabled, 0 unanswered)
> Socket:: udp:10.27.193.119:5060
> Methods:: 4294967295
> Contact:: sip:sip at 10.27.194.54 Q=1
> Expires:: 6782
> Callid:: 2 at 10.27.194.54
> Cseq:: 6
> User-agent:: oSIP/wicsip-3.4.13
> State:: CS_NEW
> Flags:: 1
> Cflag:: 34 (hb enabled, 0 unanswered)
> Socket:: udp:10.27.193.119:5060
> Methods:: 4294967295
>
> ... and here's a snippet of the openser.cfg file that is related:
>
> $var(aor) = "sip:hmp at wic.west.com";
> lookup("location","b","$var(aor)");
> xlog("L_DBG", "sending to hmp: $mb, $ru, $rs\n");
> switch ($retcode) {
> case -1: # no contact
> xlog("L_ERR", "01000001 $pp Forwarding to HMP failed -- no registered contact. r-uri: $ru, callid: $ci, p-charging-vector: $(hdr(P-Charging-Vector)), contact: $ct\n");
> sl_send_reply("404", "Not Found");
> exit;
> case -3: # internal error
> xlog("L_ERR", "01000001 $pp Forwarding to HMP failed. r-uri: $ru, callid: $ci, p-charging-vector: $(hdr(P-Charging-Vector)), contact: $ct\n");
> sl_send_reply("404", "Not Found");
> exit;
> case -2: # method not supported
> xlog("L_ERR", "01000001 $pp Forwarding to HMP failed. r-uri: $ru, callid: $ci, p-charging-vector: $(hdr(P-Charging-Vector)), contact: $ct\n");
> sl_send_reply("405", "Not Found");
> exit;
> }
> if (! t_relay() ) {
> sl_reply_error();
> }
> exit;
>
> A tcpdump has verified that the first contact listed is the one selected by the lookup() function even though the q-value of that contact is less than the second contact in the list.
>
> I'm not interested in parallel forking but, instead, want to forward requests to the least-loaded endpoint. Am I doing something wrong?
>
> Thanks!
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
--
Bogdan-Andrei Iancu
OpenSIPS Bootcamp
20 - 24 September 2010, Frankfurt, Germany
www.voice-system.ro
More information about the Users
mailing list