[OpenSIPS-Users] Registrar's lookup() function not returning contact with greatest q-value
Pauba, Kevin L
KLPauba at west.com
Tue Aug 3 22:50:44 CEST 2010
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!
More information about the Users
mailing list