Hey all,
I've got two layers of Kamailio proxies running. One set of edge proxies that are parking outbound connections and doing load balancing to a set of registrar/proxies. This is working well with one exception:
I can't seem to get t_load_contacts/t_next_contacts working correctly for handling multiple outbound connections. It *appears* to work (though I haven't extensively tested) whenever there's more than one registration binding for an AOR. However, when there's only one, I get:
8(27) DEBUG: tm [t_serial.c:191]: t_load_contacts(): nr_branches is 0 8(27) DEBUG: tm [t_serial.c:194]: t_load_contacts(): nothing to do - only one contact! 8(27) DEBUG: tm [t_serial.c:455]: t_next_contacts(): no contacts in contacts_avp - we are done! 8(27) ERROR: <script>: t_next_contacts() failed
I tried omitting the call to t_next_contacts(), thinking it should possibly only be used in failure_route. But when I do that (while leaving t_load_contacts), I get:
5(24) ERROR: tm [t_fwd.c:1730]: t_forward_nonack(): ERROR: t_forward_nonack: no branches for forwarding 5(24) WARNING: <core> [receive.c:258]: receive_msg(): error while trying script
The relevant part of the config is:
if (!lookup("location")) { $var(rc) = $rc; switch ($var(rc)) { case -1: xlog("L_INFO", "$ci|log|lookup of contacts for $ru returned no results\r\n"); send_reply("404", "Not Found"); exit; case -3: xlog("L_INFO", "$ci|log|lookup of contacts for $ru failed with code $var(rc)\r\n"); send_reply("404", "Not Found"); exit; case -2: send_reply("405", "Method Not Allowed"); exit; } }
if (!t_load_contacts() || !t_next_contacts()) { xlog("L_ERR", "t_load_contacts() failed\n"); sl_reply_error(); t_release(); exit; }
Am I missing something else here? Note: it works fine if I remove t_load_contacts/t_next_contacts, but then I don't get proper handling of multiple sip.instance bindings/differing q values.
Best, Colin
Colin Morelli writes:
8(27) DEBUG: tm [t_serial.c:191]: t_load_contacts(): nr_branches is 0 8(27) DEBUG: tm [t_serial.c:194]: t_load_contacts(): nothing to do - only one contact! 8(27) DEBUG: tm [t_serial.c:455]: t_next_contacts(): no contacts in contacts_avp - we are done! 8(27) ERROR: <script>: t_next_contacts() failed
you "relevant part of the config" does not produce the above error message.
t_load_contacts(): nothing to do - only one contact! tells that there is only one branch in the set.
-- Juha
Juha,
I changed the message between when I copied the code and the logs. Those lines are the lines that produce the error message.
As I mentioned in the original message - I'm aware that there's only one branch in the set. That is the case that this doesn't work. When there's one registration binding in the locations table, t_load_contacts doesn't seem to do anything and as a result t_next_contacts fails. Presumably I could add a special case to detect when there's only a single binding by looking at $branch(count), and not run this code, but that feels like a case that t_load_contacts *should* handle itself, no?
Best, Colin
On Sun, Jul 24, 2016 at 12:35 PM Juha Heinanen jh@tutpro.com wrote:
Colin Morelli writes:
8(27) DEBUG: tm [t_serial.c:191]: t_load_contacts(): nr_branches is 0 8(27) DEBUG: tm [t_serial.c:194]: t_load_contacts(): nothing to do -
only
one contact! 8(27) DEBUG: tm [t_serial.c:455]: t_next_contacts(): no contacts in contacts_avp - we are done! 8(27) ERROR: <script>: t_next_contacts() failed
you "relevant part of the config" does not produce the above error message.
t_load_contacts(): nothing to do - only one contact! tells that there is only one branch in the set.
-- Juha
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Colin Morelli writes:
When there's one registration binding in the locations table, t_load_contacts doesn't seem to do anything and as a result t_next_contacts fails.
t_next_contacts() does work as specified in README:
Function returns 1 if contacts_avp was not empty and a destination set was successfully added, returns -2 if contacts_avp was empty and thus there was nothing to do, and returns -1 in case of an error (see syslog).
so you just have to test the return value accordingly.
-- juha
I'm not suggesting that t_next_contacts deviates from the README. I'm looking for its specific use case when combined with the outbound module. At the very least, the example registrar configuration here: http://www.kamailio.org/docs/modules/4.4.x/modules/outbound.html is incomplete, in that it will always result in this error when there's only one binding in the registrations table.
I suppose it's just a matter of checking for t_next_contacts() == -1 in the initial fork, and then check for < 0 in subsequent failure routes. I apologize if my original message was unclear, but this was a request for clarification, not a bug report - though I will try to make a PR for the outbound documentation page when I get this working.
Best, Colin
On Sun, Jul 24, 2016 at 12:51 PM Juha Heinanen jh@tutpro.com wrote:
Colin Morelli writes:
When there's one registration binding in the locations table, t_load_contacts doesn't seem to do anything and as a result t_next_contacts fails.
t_next_contacts() does work as specified in README:
Function returns 1 if contacts_avp was not empty and a destination set was successfully added, returns -2 if contacts_avp was empty and thus there was nothing to do, and returns -1 in case of an error (see syslog).
so you just have to test the return value accordingly.
-- juha
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users