I would like to forward all incoming calls that are not answered from kamailio, to my
asterisk voicemail server. - I have not setup any Realtime Integration.
I am using the "Redirected Dialed Number Information Service" header and calling
"554(a)192.168.1.134" which is my voicemail server.
Forwarding succeeds when the subscriber is not registered to kamailio:
Nov 7 16:19:45 spock /usr/sbin/kamailio[17606]: ERROR: <script>: =============User
sip:6297@192.168.1.131 not found here, going to voicemail=============
Nov 7 16:19:45 spock /usr/sbin/kamailio[17606]: ERROR: <script>: #012 RDNIS =
sip:297@192.168.1.134
Nov 7 16:19:45 spock /usr/sbin/kamailio[17606]: ERROR: <script>:
=============forwarding to voicemail1, RDNIS: sip:297@192.168.1.134 ===========
I tried to modify the failure route in order to also forward not answered (failed?) calls
to asterisk mailbox but i get the following error and the call is never forwarded:
Nov 7 16:19:25 spock /usr/sbin/kamailio[17609]: ERROR: <script>: transaction
canceled
Nov 7 16:19:25 spock /usr/sbin/kamailio[17609]: ERROR: <script>: #012 RDNIS =
sip:297@192.168.1.134
Nov 7 16:19:25 spock /usr/sbin/kamailio[17609]: ERROR: <script>:
=============forwarding to voicemail1, RDNIS: sip:297@192.168.1.134 ===========
Nov 7 16:19:25 spock /usr/sbin/kamailio[17609]: ERROR: tm [tm.c:1679]: _w_t_relay_to():
t_forward_noack failed
Nov 7 16:19:25 spock /usr/sbin/kamailio[17609]: ERROR: sl [sl_funcs.c:392]:
sl_reply_error(): stateless error reply used: transaction canceled (487/SL)
failure and voicemail routes are slightly modified from the default config:
route[LOCATION] {
#!ifdef WITH_SPEEDDIAL
# search for short dialing - 2-digit extension
if($rU=~"^[0-9][0-9]$") {
if(sd_lookup("speed_dial")) {
route(SIPOUT);
}
}
#!endif
#!ifdef WITH_ALIASDB
# search in DB-based aliases
if(alias_db_lookup("dbaliases")) {
route(SIPOUT);
}
#!endif
$avp(oexten) = $rU;
if (!lookup("location")) {
xlog("=============User $ru not found here, going to
voicemail=============\n");
$var(rc) = $rc;
route(TOVOICEMAIL);
t_newtran();
switch ($var(rc)) {
case -1:
case -3:
send_reply("404", "Not Found");
exit;
case -2:
send_reply("405", "Method Not
Allowed");
exit;
}
}
# when routing via usrloc, log the missed calls also
if (is_method("INVITE")) {
setflag(FLT_ACCMISSED);
}
route(RELAY);
exit;
}
route[TOVOICEMAIL] {
#!ifdef WITH_VOICEMAIL
if(!is_method("INVITE|SUBSCRIBE")) return;
# check if VoiceMail server IP is defined
if (strempty($sel(cfg_get.voicemail.srv_ip))) {
xlog("SCRIPT: VoiceMail routing enabled but IP not defined\n");
return;
}
if(is_method("INVITE")) {
$var(RDNIS)=$di;
xlog("\n RDNIS = $var(RDNIS) \n");
if($avp(oexten)==$null) return;
# $ru = "sip:" + $avp(oexten) + "@" +
$sel(cfg_get.voicemail.srv_ip + ";transport=udp")
# + ":" + $sel(cfg_get.voicemail.srv_port);
xlog("=============forwarding to voicemail1, RDNIS: $di ===========
");
$ru = "sip:554@192.168.1.134:5060";
} else {
if($rU==$null) return;
# $ru = "sip:" + $rU + "@" +
$sel(cfg_get.voicemail.srv_ip + ";transport=udp")
# + ":" + $sel(cfg_get.voicemail.srv_port);
xlog("=============forwarding to voicemail2, RDNIS: $di ===========
");
$ru = "sip:554@192.168.1.134:5060";
}
route(RELAY);
exit;
#!endif
return;
}
# Manage failure routing cases
failure_route[MANAGE_FAILURE] {
route(NATMANAGE);
if (t_is_canceled()) {
#modified here
xlog("transaction canceled\n");
route(TOVOICEMAIL);
#exit;
#/modified
}
#!ifdef WITH_BLOCK3XX
# block call redirect based on 3xx replies.
if (t_check_status("3[0-9][0-9]")) {
t_reply("404","Not found");
exit;
}
#!endif
#!ifdef WITH_BLOCK401407
# block call redirect based on 401, 407 replies.
if (t_check_status("401|407")) {
t_reply("404","Not found");
exit;
}
#!endif
#!ifdef WITH_VOICEMAIL
# serial forking
# - route to voicemail on busy or no answer (timeout)
if (t_check_status("486|408")) {
$du = $null;
xlog("============= Route failure, forwarding to voicemail
=============");
route(TOVOICEMAIL);
exit;
}
#!endif
}