Page 1 of 1

Problems with dialplan failover

PostPosted: Tue Sep 26, 2023 9:16 am
by perlmutr
NOTE Thruout the post I have changed @ to % because while posting I kept saying too many URL's and would not allow me to post

I have 3 sip carriers. I round robin calls thru the 3 and when a call fails I want to try it on the other carriers.

My dialplan is as follows:

exten => _1NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _1NXXNXXXXXX,n,GotoIf($[${sip_provider} = 2]?10)
exten => _1NXXNXXXXXX,n,GotoIf($[${sip_provider} = 3]?20)

exten => _1NXXNXXXXXX,n,Set(GLOBAL(sip_provider)=2)
exten => _1NXXNXXXXXX,n,Noop(leadgen Dialing thru aka Customer: ${EXTEN} )
exten => _1NXXNXXXXXX,n,Dial(SIP/${EXTEN:}%aka,,To)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?30)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?30)
exten => _1NXXNXXXXXX,n,Hangup

exten => _1NXXNXXXXXX,10,Set(GLOBAL(sip_provider)=3)
exten => _1NXXNXXXXXX,n,Noop(leadgen Dialing thru Dawz Customer: ${EXTEN})
exten => _1NXXNXXXXXX,n,Dial(SIP/${EXTEN:}%Dawz,,To)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?40)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?40)
exten => _1NXXNXXXXXX,n,Hangup

exten => _1NXXNXXXXXX,20,Set(GLOBAL(sip_provider)=1)
exten => _1NXXNXXXXXX,n,Noop(leadgen Dialing thru come2voip Customer: ${EXTEN})
exten => _1NXXNXXXXXX,n,Dial(SIP/12670${EXTEN:}%come2voip,,To)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?50)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?50)
exten => _1NXXNXXXXXX,n,Hangup

exten => _1NXXNXXXXXX,30,Noop(leadgen Dialing Failover thru dawz Customer: ${EXTEN})
exten => _1NXXNXXXXXX,n, Dial(SIP/${EXTEN:}%Dawz,,To)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?35)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?35)
exten => _1NXXNXXXXXX,n,Hangup

exten => _1NXXNXXXXXX,35,Noop(leadgen Dialing Failover thru come2voip Customer: ${EXTEN})
exten => _1NXXNXXXXXX,n,Dial(SIP/12670${EXTEN:}%come2voip,,To)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?60)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?60)
exten => _1NXXNXXXXXX,n,Hangup

exten => _1NXXNXXXXXX,40,Noop(leadgen Dialing Failover thru aka Customer: ${EXTEN})
exten => _1NXXNXXXXXX,n,Dial(SIP/${EXTEN:}%aka,,To)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?45)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?45)
exten => _1NXXNXXXXXX,n,Hangup

exten => _1NXXNXXXXXX,45,Noop(leadgen Dialing Failover thru come2voip Customer: ${EXTEN})
exten => _1NXXNXXXXXX,n,Dial(SIP/12670${EXTEN:}%come2voip,,To)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?60)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?60)
exten => _1NXXNXXXXXX,n,Hangup

exten => _1NXXNXXXXXX,50,Noop(leadgen Dialing Failover thru aka Customer: ${EXTEN})
exten => _1NXXNXXXXXX,n, Dial(SIP/${EXTEN:}%aka,,To)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?55)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?55)
exten => _1NXXNXXXXXX,n,Hangup

exten => _1NXXNXXXXXX,55,Noop(leadgen Dialing Failover thru Dawz Customer: ${EXTEN})
exten => _1NXXNXXXXXX,n, Dial(SIP/${EXTEN:}%Dawz,,To)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CHANUNAVAIL"]?60)
exten => _1NXXNXXXXXX,n,GotoIf($["${DIALSTATUS}" = "CONGESTION"]?60)
exten => _1NXXNXXXXXX,n,Hangup

exten => _1NXXNXXXXXX,60,Noop(leadgen Failover all routes failed: to Customer: ${EXTEN})
exten => _1NXXNXXXXXX,n,Hangup()


Looking at a call which failed, i see the following in the carrier log:

UNIQUE ID | CALL DATE | SERVER IP | LEAD ID | HANGUP CAUSE | DIAL STATUS | CHANNEL | DIAL TIME | ANSWERED TIME | SIP CODE | SIP HANGUP REASON | PHONE NUMBER |
+----------------------+---------------------+-----------------+-----------+--------------+-------------+------------------------------------------+-----------+---------------+----------+--------------------------------+--------------+
| 1695391237.4 | 2023-09-22 10:00:37 | 192.168.10.21 | 33664274 | 19 | BUSY | Local/12392028817%default-00000000;2 | 0 | 0 | 480 | No Routes Found) | 2392028817

From my server console I see the following:

[Sep 22 10:00:37] VERBOSE[8171] dial.c: Called 12392028817%default
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Executing [12392028817%default:1] AGI("Local/12392028817%default-00000000;2", "agi://127.0.0.1:4577/call_log") in new stack
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] res_agi.c: AGI Script Executing Application: (EXEC) Options: (Set(_CAMPCUST=INSFRONT))
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] res_agi.c: <Local/12392028817%default-00000000;2>AGI Script agi://127.0.0.1:4577/call_log completed, returning 0
[Sep 22 10:00:37] WARNING[8172][C-00000001] ast_expr2.fl: ast_yyerror(): syntax error: syntax error, unexpected '=', expecting $end; Input:
= 2
^
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Executing [12392028817%default:2] GotoIf("Local/12392028817%default-00000000;2", "?10") in new stack
[Sep 22 10:00:37] WARNING[8172][C-00000001] ast_expr2.fl: ast_yyerror(): syntax error: syntax error, unexpected '=', expecting $end; Input:
= 3
^
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Executing [12392028817%default:3] GotoIf("Local/12392028817%default-00000000;2", "?20") in new stack
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Executing [12392028817%default:4] Set("Local/12392028817%default-00000000;2", "GLOBAL(sip_provider)=2") in new stack
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx_variables.c: Setting global variable 'sip_provider' to '2'
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Executing [12392028817%default:5] NoOp("Local/12392028817%default-00000000;2", "leadgen Dialing thru aka Customer: 12392028817 ") in new stack
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Executing [12392028817%default:6] Dial("Local/12392028817%default-00000000;2", "SIP/12392028817%aka,,To") in new stack
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] netsock2.c: Using SIP RTP CoS mark 5
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] app_dial.c: Called SIP/12392028817%aka
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] app_dial.c: SIP/aka-00000002 redirecting info has changed, passing it to Local/12392028817%default-00000000;2
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] app_dial.c: SIP/aka-00000002 is busy
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] app_dial.c: Everyone is busy/congested at this time (1:1/0/0)
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Executing [12392028817%default:7] GotoIf("Local/12392028817%default-00000000;2", "0?30") in new stack
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Executing [12392028817%default:8] GotoIf("Local/12392028817%default-00000000;2", "0?30") in new stack
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Executing [12392028817%default:9] Hangup("Local/12392028817%default-00000000;2", "") in new stack
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Spawn extension (default, 12392028817, 9) exited non-zero on 'Local/12392028817%default-00000000;2'
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] pbx.c: Executing [h%default:1] AGI("Local/12392028817%default-00000000;2", "agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----19-----BUSY---------------SIP 480 No Routes Found)") in new stack
[Sep 22 10:00:37] VERBOSE[8172][C-00000001] res_agi.c: <Local/12392028817%default-00000000;2>AGI Script agi://127.0.0.1:4577/call_log--HVcauses ... -------SIP 480 No Routes Found) completed, returning 0
[Sep 22 10:00:38] VERBOSE[8154][C-00000000] res_rtp_asterisk.c: 0x7fc7fc00b700 -- Strict RTP learning complete - Locking on source address 120.29.69.14:54078

It tried the call thru the first carrier and never tried the failover.

with other errors such as 503 return is does try the other carriers.

[Sep 22 10:02:58] VERBOSE[8631] dial.c: Called 12392572052%default
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:1] AGI("Local/12392572052%default-00000014;2", "agi://127.0.0.1:4577/call_log") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] res_agi.c: AGI Script Executing Application: (EXEC) Options: (Set(_CAMPCUST=INSFRONT))
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] res_agi.c: <Local/12392572052%default-00000014;2>AGI Script agi://127.0.0.1:4577/call_log completed, returning 0
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:2] GotoIf("Local/12392572052%default-00000014;2", "0?10") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:3] GotoIf("Local/12392572052%default-00000014;2", "1?20") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx_builtins.c: Goto (default,12392572052,20)
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:20] Set("Local/12392572052%default-00000014;2", "GLOBAL(sip_provider)=1") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx_variables.c: Setting global variable 'sip_provider' to '1'
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:21] NoOp("Local/12392572052%default-00000014;2", "leadgen Dialing thru come2voip Customer: 12392572052") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:22] Dial("Local/12392572052%default-00000014;2", "SIP/1267012392572052%come2voip,,To") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] netsock2.c: Using SIP RTP CoS mark 5
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] app_dial.c: Called SIP/1267012392572052%come2voip
[Sep 22 10:02:58] VERBOSE[14912][C-00000022] chan_sip.c: Got SIP response 503 "Service Unavailable" back from 216.250.131.144:5060
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] app_dial.c: SIP/come2voip-00000010 is circuit-busy
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] app_dial.c: Everyone is busy/congested at this time (1:0/1/0)
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:23] GotoIf("Local/12392572052%default-00000014;2", "0?50") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:24] GotoIf("Local/12392572052%default-00000014;2", "1?50") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx_builtins.c: Goto (default,12392572052,50)
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:50] NoOp("Local/12392572052%default-00000014;2", "leadgen Dialing Failover thru aka Customer: 12392572052") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:51] Dial("Local/12392572052%default-00000014;2", "SIP/12392572052%aka,,To") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] netsock2.c: Using SIP RTP CoS mark 5
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] app_dial.c: Called SIP/12392572052%aka
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] app_dial.c: SIP/aka-00000011 redirecting info has changed, passing it to Local/12392572052%default-00000014;2
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] app_dial.c: SIP/aka-00000011 is busy
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] app_dial.c: Everyone is busy/congested at this time (1:1/0/0)
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:52] GotoIf("Local/12392572052%default-00000014;2", "0?55") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:53] GotoIf("Local/12392572052%default-00000014;2", "0?55") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [12392572052%default:54] Hangup("Local/12392572052%default-00000014;2", "") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Spawn extension (default, 12392572052, 54) exited non-zero on 'Local/12392572052%default-00000014;2'
[Sep 22 10:02:58] WARNING[8632][C-00000022] func_hangupcause.c: Information type not recognized (SIP/come2voip-00000010,tech)
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] pbx.c: Executing [h%default:1] AGI("Local/12392572052%default-00000014;2", "agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----19-----BUSY---------------)") in new stack
[Sep 22 10:02:58] VERBOSE[8632][C-00000022] res_agi.c: <Local/12392572052%default-00000014;2>AGI Script agi://127.0.0.1:4577/call_log--HVcauses ... ----------) completed, returning 0



Is there any way for me to capture the no routes available status and try the other carriers


vicidial Version 2.14-730A SVN 3591 DB schema version 1657 asterisk version 13.38.2-vici

I have a 4 machine cluster
Database/ WEB / Dialer machine dual: quad core Xeon 2.67 GHz 48GB mem / Dialer dual: dual core Xeon 2.80 GHz 8GB mem / dialer core i5 3.0 GHz 4GB mem / dialer core-2 duo 2.93GHz 3GB mem
.. all machines have 2 nic's.. one internal and 1 external for traffic.

Re: Problems with dialplan failover

PostPosted: Tue Jul 30, 2024 11:05 pm
by williamconley
When calls "fail" you don't need to "gotoif". Just dial with the next carrier instead. If the call failed, it'll call the next carrier. If the call is answered, it'll be removed from this diaplan entirely and the next lines won't execute.