I have been trying to get outbound calls to work, and my trunk provider required authentication for outbound calls.
My trunk is registered with UAC and I use Dispatcher to select the correct trunk for the CLI making the call.
I just can’t seem to get it working, my trunk does not know how to replay to my authenticated invite and Kamailio just retransmits until it times out.
Perhaps someone can point me in the right direction, I have looked everywhere and tried so many different appraches.
The call flow should be Client Phone -> Kamailio -> Trunk and replies, Trunk -> Kamailio -> Client Phone.
# Dispatch requests route[DISPATCH] { if ($var(dispatcher_set) == $null || $var(dispatcher_set) == "") { xlog("L_INFO", "[$ci] DISPATCHER: No dispatcher set configured\n");
return; }
# DISPATCHER_OUTBOUND_SET # DISPATCHER_INBOUND_SET # DISPATCHER_ASTERISK_SET
switch($var(dispatcher_set)) { case DISPATCHER_OUTBOUND_SET: if (!ds_select_dst(DISPATCHER_OUTBOUND_SET, "4")) { xlog("L_ERR", "[$ci] DISPATCHER: No available outbound dispatcher destinations\n"); sl_send_reply("503", "Service Unavailable"); exit; }
xlog("L_INFO", "[$ci] DISPATCHER: Going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs)) from set $var(dispatcher_set)\n"); $du = "sip:{{ kamailio_sip_host }}:{{ kamailio_sip_port }}"; $avp(auth_user) = $xavp(_dsdst_=>attrs=>auth_user); $avp(auth_pass) = $xavp(_dsdst_=>attrs=>auth_pass); $avp(auth_realm) = $xavp(_dsdst_=>attrs=>auth_realm); if (is_method("INVITE")) { t_on_failure("TRUNK_AUTH"); t_relay(); exit; }
break;
case DISPATCHER_INBOUND_SET: if (!ds_select_dst(DISPATCHER_INBOUND_SET, "4")) { xlog("L_ERR", "[$ci] DISPATCHER: No available inbound dispatcher destinations\n"); sl_send_reply("503", "Service Unavailable"); exit; } break;
case DISPATCHER_ASTERISK_SET: if (!ds_select_dst(DISPATCHER_ASTERISK_SET, "4")) { xlog("L_ERR", "[$ci] DISPATCHER: No available Asterisk dispatcher destinations\n"); sl_send_reply("503", "Service Unavailable"); exit; } break;
default: xlog("L_ERR", "[$ci] DISPATCHER: Invalid dispatcher set $var(dispatcher_set)\n"); sl_send_reply("500", "Internal Server Error"); exit; }
t_on_failure("RTF_DISPATCH"); route(RELAY); exit; }
# Failure route - outbound trunk auth challenge handling failure_route[TRUNK_AUTH] { if (t_is_canceled()) { xlog("L_INFO", "[$ci] TRUNK_AUTH: Transaction canceled\n"); exit; }
if (t_check_status("401|407")) { xlog("L_INFO", "[$ci] TRUNK_AUTH: Received auth challenge for outbound trunk\n");
if ($avp(auth_user) == $null || $avp(auth_pass) == $null || $avp(auth_realm) == $null) { xlog("L_WARN", "[$ci] TRUNK_AUTH: Missing UAC auth credentials, skipping uac_auth\n"); exit; }
uac_auth(); t_relay(); exit; } }
Kind regards
Darren Carter
Hi,
What are you seeing on a pcap trace ans Logs?
Is the failure route working and the authenticated INVITE is bing sent out in response to the 401 or 407 ant you carrier is notresponding with a 100 trying to that? Or is Kamaillio just resending the original INVITE without the auth?
what specifically has the carrier specified for the Auth and transport?
I'm assuming you have definded the auth variables in the modparms.
Richard
On 25/01/2026 17:52, Darren Carter via sr-users wrote:
I have been trying to get outbound calls to work, and my trunk provider required authentication for outbound calls.
My trunk is registered with UAC and I use Dispatcher to select the correct trunk for the CLI making the call.
I just can’t seem to get it working, my trunk does not know how to replay to my authenticated invite and Kamailio just retransmits until it times out.
Perhaps someone can point me in the right direction, I have looked everywhere and tried so many different appraches.
The call flow should be Client Phone -> Kamailio -> Trunk and replies, Trunk -> Kamailio -> Client Phone.
# Dispatch requests route[DISPATCH] { if ($var(dispatcher_set) == $null || $var(dispatcher_set) == "") { xlog("L_INFO", "[$ci] DISPATCHER: No dispatcher set configured\n"); return; } # DISPATCHER_OUTBOUND_SET # DISPATCHER_INBOUND_SET # DISPATCHER_ASTERISK_SET switch($var(dispatcher_set)) { case DISPATCHER_OUTBOUND_SET: if (!ds_select_dst(DISPATCHER_OUTBOUND_SET, "4")) { xlog("L_ERR", "[$ci] DISPATCHER: No available outbound dispatcher destinations\n"); sl_send_reply("503", "Service Unavailable"); exit; } xlog("L_INFO", "[$ci] DISPATCHER: Going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs)) from set $var(dispatcher_set)\n"); $du = "sip:{{ kamailio_sip_host }}:{{ kamailio_sip_port }}"; $avp(auth_user) = $xavp(_dsdst_=>attrs=>auth_user); $avp(auth_pass) = $xavp(_dsdst_=>attrs=>auth_pass); $avp(auth_realm) = $xavp(_dsdst_=>attrs=>auth_realm); if (is_method("INVITE")) { t_on_failure("TRUNK_AUTH"); t_relay(); exit; } break; case DISPATCHER_INBOUND_SET: if (!ds_select_dst(DISPATCHER_INBOUND_SET, "4")) { xlog("L_ERR", "[$ci] DISPATCHER: No available inbound dispatcher destinations\n"); sl_send_reply("503", "Service Unavailable"); exit; } break; case DISPATCHER_ASTERISK_SET: if (!ds_select_dst(DISPATCHER_ASTERISK_SET, "4")) { xlog("L_ERR", "[$ci] DISPATCHER: No available Asterisk dispatcher destinations\n"); sl_send_reply("503", "Service Unavailable"); exit; } break; default: xlog("L_ERR", "[$ci] DISPATCHER: Invalid dispatcher set $var(dispatcher_set)\n"); sl_send_reply("500", "Internal Server Error"); exit; } t_on_failure("RTF_DISPATCH"); route(RELAY); exit; }
# Failure route - outbound trunk auth challenge handling failure_route[TRUNK_AUTH] { if (t_is_canceled()) { xlog("L_INFO", "[$ci] TRUNK_AUTH: Transaction canceled\n"); exit; } if (t_check_status("401|407")) { xlog("L_INFO", "[$ci] TRUNK_AUTH: Received auth challenge for outbound trunk\n"); if ($avp(auth_user) == $null || $avp(auth_pass) == $null || $avp(auth_realm) == $null) { xlog("L_WARN", "[$ci] TRUNK_AUTH: Missing UAC auth credentials, skipping uac_auth\n"); exit; } uac_auth(); t_relay(); exit; } }
Kind regards
Darren Carter
Kamailio - Users Mailing List - Non Commercial Discussions --sr-users@lists.kamailio.org To unsubscribe send an email tosr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Hi Darren
I think I may be trying to sort a similar problem with outbound authenticated trunks, although without dispatch - See email thread with subject "[SR-Users] Issue adding SIP Trunk UAC Auth” 17th - 21st of Jan 2026
Although in my case as soon as I add UAC Auth I see the following error in the logs and replies from the responses from the outbound trunk carrier no longer get relayed to the client. They just bounce off kamailio until it times out. DEBUG: {2 31528 INVITE 710ed27a-da6b-4362-b598-e4cd72c765e2} tm [t_lookup.c:906]: t_reply_matching(): poor reply ids - index 19664 label 0 branch 7491888 loopl 32/32 DEBUG: {2 31528 INVITE 710ed27a-da6b-4362-b598-e4cd72c765e2} tm [t_lookup.c:1009]: t_reply_matching(): failure to match a transaction
So far it seems that the problem is the transaction not getting matched. I’ve not diagnosed it any further yet.
Mark
On 25 Jan 2026, at 17:52, Darren Carter via sr-users sr-users@lists.kamailio.org wrote:
I have been trying to get outbound calls to work, and my trunk provider required authentication for outbound calls.
My trunk is registered with UAC and I use Dispatcher to select the correct trunk for the CLI making the call.
I just can’t seem to get it working, my trunk does not know how to replay to my authenticated invite and Kamailio just retransmits until it times out.
Perhaps someone can point me in the right direction, I have looked everywhere and tried so many different appraches.
The call flow should be Client Phone -> Kamailio -> Trunk and replies, Trunk -> Kamailio -> Client Phone.
# Dispatch requests route[DISPATCH] { if ($var(dispatcher_set) == $null || $var(dispatcher_set) == "") { xlog("L_INFO", "[$ci] DISPATCHER: No dispatcher set configured\n");
return; } # DISPATCHER_OUTBOUND_SET # DISPATCHER_INBOUND_SET # DISPATCHER_ASTERISK_SET switch($var(dispatcher_set)) { case DISPATCHER_OUTBOUND_SET: if (!ds_select_dst(DISPATCHER_OUTBOUND_SET, "4")) { xlog("L_ERR", "[$ci] DISPATCHER: No available outbound dispatcher destinations\n"); sl_send_reply("503", "Service Unavailable"); exit; } xlog("L_INFO", "[$ci] DISPATCHER: Going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs)) from set $var(dispatcher_set)\n"); $du = "sip:{{ kamailio_sip_host }}:{{ kamailio_sip_port }}"; $avp(auth_user) = $xavp(_dsdst_=>attrs=>auth_user); $avp(auth_pass) = $xavp(_dsdst_=>attrs=>auth_pass); $avp(auth_realm) = $xavp(_dsdst_=>attrs=>auth_realm); if (is_method("INVITE")) { t_on_failure("TRUNK_AUTH"); t_relay(); exit; } break; case DISPATCHER_INBOUND_SET: if (!ds_select_dst(DISPATCHER_INBOUND_SET, "4")) { xlog("L_ERR", "[$ci] DISPATCHER: No available inbound dispatcher destinations\n"); sl_send_reply("503", "Service Unavailable"); exit; } break; case DISPATCHER_ASTERISK_SET: if (!ds_select_dst(DISPATCHER_ASTERISK_SET, "4")) { xlog("L_ERR", "[$ci] DISPATCHER: No available Asterisk dispatcher destinations\n"); sl_send_reply("503", "Service Unavailable"); exit; } break; default: xlog("L_ERR", "[$ci] DISPATCHER: Invalid dispatcher set $var(dispatcher_set)\n"); sl_send_reply("500", "Internal Server Error"); exit; } t_on_failure("RTF_DISPATCH"); route(RELAY); exit;}
# Failure route - outbound trunk auth challenge handling failure_route[TRUNK_AUTH] { if (t_is_canceled()) { xlog("L_INFO", "[$ci] TRUNK_AUTH: Transaction canceled\n"); exit; }
if (t_check_status("401|407")) { xlog("L_INFO", "[$ci] TRUNK_AUTH: Received auth challenge for outbound trunk\n"); if ($avp(auth_user) == $null || $avp(auth_pass) == $null || $avp(auth_realm) == $null) { xlog("L_WARN", "[$ci] TRUNK_AUTH: Missing UAC auth credentials, skipping uac_auth\n"); exit; } uac_auth(); t_relay(); exit; }}
Kind regards
Darren Carter
Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Mark