The ViciDial Call Menu Hangup Trap: Why Abandoned IVR Sessions
calricon / field note
Discover why abandoned caller sessions in ViciDial Call Menus
The ViciDial Call Menu Hangup Trap: Why Abandoned IVR Sessions Strand Carrier Trunks
In enterprise contact centers utilizing ViciDial for blended inbound and outbound operations, incoming Direct Inward Dialing (DID) numbers frequently route callers through interactive Call Menus (IVRs) before queueing for live agents. However, contact center operations teams frequently uncover an expensive operational defect: when inbound callers disconnect during audio prompts or menu navigation without selecting an option, Asterisk fails to terminate the underlying media channel. The session remains active in the PBX core, looping audio prompts to a closed network socket for hours. Telecommunications carrier trunks remain held off-hook, incurring thousands of dollars in phantom usage billing and exhausting inbound trunk concurrency limits. The defect is caused by missing hangup event handlers and unconstrained loop routing within ViciDial Call Menu dialplans.
Problem Diagnosis & Root Cause Architecture
The failure occurs due to an architectural breakdown between carrier SIP signaling, Asterisk channel execution loops, and ViciDial database tracking tables:
- Asymmetric SIP Disconnect Signaling: When an inbound caller hangs up their phone while listening to an IVR prompt, the originating carrier sends a
SIP/2.0 BYEto Asterisk. While Asterisk receives the network packet and sets the internal channel hangup flag, the executing dialplan application (such asBackground()orWaitExten()) does not automatically break its execution loop unless explicitly monitored by the script layer. - Infinite Timeout Loop Routing: In default Call Menu configurations, administrators configure the timeout option (
t) or invalid option (i) to repeat the menu prompt. If an abandoned channel re-enters the menu without an explicit${CHANNEL(state)}or hangup evaluation, Asterisk restarts prompt playback. Because the channel is marked in an internal hangup state, audio write errors are suppressed, allowing the loop to persist indefinitely. - Database State Desynchronization: ViciDial logs active inbound sessions in the
vicidial_auto_callstable under the statusIVR. Because the standard call termination script (agi-VDAD_ALL_inbound.agi) was never reached, the database record remains active. Downstream monitoring dashboards report inflated queue counts, and carrier channel allocation counters remain pinned at maximum capacity. - Carrier Trunk Starvation: As stranded IVR channels accumulate throughout the business day, available channels on the SIP carrier trunk group are depleted. Legitimate customer calls arriving at the contact center encounter
SIP/2.0 503 Maximum Channels Exceededor fast-busy tones, directly impacting inbound service level agreements.
"Playing IVR audio in an unconstrained loop without immediate hangup trapping turns abandoned calls into permanent channel zombies. When carrier disconnects are ignored by dialplan state machines, wholesale telecom minutes accumulate on empty lines."
Why Standard Implementations Fail
Setting Call Menu Timeout to 10 Seconds
Reducing the Call Menu timeout parameter in ViciDial Admin from 60 seconds to 10 seconds does not resolve the issue. If the timeout action routes back to the same Call Menu, the channel simply loops faster. Asterisk continues cycling through the prompt every 10 seconds, keeping the carrier SIP channel active indefinitely.
Relying on Default Asterisk AbsoluteTimeout
Setting TIMEOUT(absolute)=1800 terminates the channel after 30 minutes, but still permits half an hour of wasted carrier trunk billing per abandoned caller. Under high inbound call volumes where hundreds of callers drop out of IVR queues daily, 30 minutes of phantom billing per call quickly generates thousands of dollars in unnecessary telecom expenses.
Configuring Global RTP Inactivity Timers
While configuring rtp_timeout in sip.conf or pjsip.conf terminates silent channels, it fails during Call Menu execution. Because Asterisk is actively transmitting outbound audio prompts (announcements, music, or menus), the channel is not idle from an RTP perspective. The gateway continues streaming packets, preventing RTP inactivity timers from ever engaging.
Production-Tested Step-by-Step Engineering Playbook
Step 1: Diagnose Stranded IVR Channels via Asterisk CLI and Database Queries
Inspect Asterisk active channels and MariaDB tables to verify whether open channels are trapped in Call Menu loops without live callers.
# Check active Asterisk channels running in IVR contexts for more than 10 minutes
asterisk -rx "core show channels verbose" | grep -E "default|vicidial-auto" | awk '$11 > "10:00" {print $1, $2, $11}' | sed 20q
# Sample output demonstrating stranded channels:
# SIP/carrier_trunk-0004812a default 1001 1 Up Background(custom/welcome_menu) 42:15
# SIP/carrier_trunk-0004812b default 1001 1 Up WaitExten(10) 38:04
# Inspect orphaned IVR records inside the ViciDial database
mysql -u cron -p -e "SELECT auto_call_id, campaign_id, phone_number, status, call_time FROM asterisk.vicidial_auto_calls WHERE status='IVR' AND call_time < NOW() - INTERVAL 15 MINUTE;"Step 2: Configure Explicit h-Extension Cleanup in Inbound Call Menu Dialplans
Ensure that Asterisk dialplans include dedicated hangup extensions (exten => h) that trap carrier disconnect events and cleanly purge state records.
; /etc/asterisk/extensions-vicidial-ivr.conf
[custom-callmenu-trap]
exten => s,1,NoOp(Inbound Call Menu with Hangup Trap: ${CALLERID(num)})
same => n,Answer()
same => n,Set(LOOP_COUNT=0)
; Menu prompt playback loop with explicit hangup verification
same => n(play_menu),Set(LOOP_COUNT=$[${LOOP_COUNT} + 1])
same => n,GotoIf($[${LOOP_COUNT} > 3]?hangup_abandon)
same => n,GotoIf($["${CHANNEL(state)}" != "Up"]?hangup_abandon)
same => n,Background(custom/welcome_menu)
same => n,WaitExten(10)
; Explicit Hangup Trapping
exten => h,1,NoOp(Caller hung up during IVR execution - Purging Channel: ${CHANNEL})
same => n,AGI(agi-IVR_hangup_check.agi)
same => n,Hangup()
exten => t,1,NoOp(Menu Timeout - Evaluating Loop)
same => n,Goto(s,play_menu)
exten => i,1,NoOp(Invalid Entry)
same => n,Playback(invalid)
same => n,Goto(s,play_menu)
exten => hangup_abandon,1,NoOp(Max loops reached or caller hung up)
same => n,Playback(vm-goodbye)
same => n,Hangup()Step 3: Implement Max Loop Thresholds and Route Actions in ViciDial Admin
Configure ViciDial Call Menu parameters to enforce a finite loop limit and define a deterministic fallback route when callers fail to respond.
-- SQL update to enforce strict timeout and loop parameters across Call Menus
UPDATE vicidial_call_menu
SET menu_timeout = 8,
menu_timeout_exten = 'hangup_abandon',
menu_invalid_exten = 'hangup_abandon',
menu_repeat = 2
WHERE menu_id = 'WELCOME_MENU';In ViciDial Admin, set the Call Menu Timeout Action to HANGUP or route to an active voicemail box rather than re-triggering the same Call Menu infinitely.
Step 4: Deploy an In-Band AGI Hangup Verification Wrapper
Deploy a lightweight AGI script that executes on every Call Menu loop iteration and h extension execution, immediately purging database records and issuing AMI channel hangups.
# /var/lib/asterisk/agi-bin/agi-IVR_hangup_check.agi
#!/usr/bin/perl
use strict;
use warnings;
use Asterisk::AGI;
use DBI;
my $AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
my $channel = $input{channel} || '';
my $uniqueid = $input{uniqueid} || '';
# Connect to ViciDial database
my $dbh = DBI->connect("DBI:mysql:database=asterisk;host=127.0.0.1", "cron", "1234", {RaiseError => 0, PrintError => 0});
if ($dbh && $uniqueid) {
# Remove orphaned record from active calls table
$dbh->do("UPDATE vicidial_auto_calls SET status = 'DISCONN' WHERE uniqueid = ?", undef, $uniqueid);
# Update closer log with clean disconnect status
$dbh->do("UPDATE vicidial_closer_log SET status = 'DROP', end_epoch = UNIX_TIMESTAMP() WHERE uniqueid = ? AND status = 'IVR'", undef, $uniqueid);
$dbh->disconnect();
}
$AGI->hangup();
exit(0);Ensure appropriate execution permissions are set on the AGI script:
chmod +x /var/lib/asterisk/agi-bin/agi-IVR_hangup_check.agi
chown asterisk:asterisk /var/lib/asterisk/agi-bin/agi-IVR_hangup_check.agiStep 5: Production Verification and Caller Disconnect Stress Testing
Validate that inbound callers disconnecting during Call Menu execution release Asterisk channels and carrier trunks immediately.
# Simulate an inbound call that hangs up 3 seconds into Call Menu playback using sipp
sipp -sn uac https://www.google.com/url?q=http://10.244.2.10:5060&source=gmail&ust=1794429268834000&sa=E (https://www.google.com/url?q=https://www.google.com/url?q%3Dhttp://10.244.2.10:5060%26amp;source%3Dgmail%26amp;ust%3D1794429016386000%26amp;sa%3DE&source=gmail&ust=1794429268834000&sa=E) -s 1001 -m 1 -d 3000 -trace_msg -trace_err
# Monitor Asterisk console logs to verify immediate channel teardown
asterisk -rx "core show channels" | grep "welcome_menu"
# Sample verification output confirming clean channel termination:
# [DEBUG] pbx.c:4812 Channel 'SIP/carrier_trunk-0004812a' received HANGUP during Background()
# [INFO] Executing [h@custom-callmenu-trap:1] NoOp("Caller hung up during IVR execution")
# [INFO] agi-IVR_hangup_check.agi: Successfully purged vicidial_auto_calls for uniqueid 1731238412.94
# Channel 'SIP/carrier_trunk-0004812a' released in 0.042 seconds
# Verify zero orphaned IVR sessions inside the database
mysql -u cron -p -e "SELECT COUNT(*) FROM asterisk.vicidial_auto_calls WHERE status='IVR';"
# Expected output: 0By implementing explicit h-extension cleanup, enforcing finite menu repetition boundaries, and deploying an automated AGI hangup verification wrapper, ViciDial contact centers eliminate stranded Call Menu channels. Telecom carrier trunks release immediately upon caller disconnect, preventing phantom billing and ensuring full trunk availability for customer calls.
Experiencing this issue in your production systems?
Calricon conducts senior-level VoIP, SIP trunking, Asterisk, and cloud infrastructure audits. We review your live configs, identify packet drops or contention bottlenecks, and provide exact remediation runbooks.