From d5a90e49f3e5792f037599b14cc285d4293f0fb0 Mon Sep 17 00:00:00 2001 From: mattf Date: Wed, 2 Sep 2026 20:09:25 +0000 Subject: [PATCH] Fixes for systems with overloaded Khomp servers on outbound auto-dialing git-svn-id: svn://192.168.202.10@4019 3d104415-ff17-0410-8863-d5cf3c621b8a --- agi/agi-VDAD_ALL_outbound.agi | 11 ++++++++++- bin/FastAGI_log.pl | 8 ++++++++ .../FastAGIServer/AGIHandlers/VDAD_ALL_outbound.pm | 11 ++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/agi/agi-VDAD_ALL_outbound.agi b/agi/agi-VDAD_ALL_outbound.agi index 9c9b46bc..d9c91614 100644 --- a/agi/agi-VDAD_ALL_outbound.agi +++ b/agi/agi-VDAD_ALL_outbound.agi @@ -45,7 +45,7 @@ #exten => 8366,4,AGI(agi-VDAD_ALL_outbound.agi,SURVEY-----LB-----US_pol_survey_hello-----1238-----8-----US_pol_survey_transfer-----US_thanks_no_contact-----OPTOUT-----DNC) #exten => 8366,5,Hangup # -# Copyright (C) 2025 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2026 Matt Florell LICENSE: AGPLv2 # # changes: # 80218-2027 - First Build @@ -136,6 +136,7 @@ # 250924-2150 - Added code for deprecation of "Monitor" application after Asterisk 20 # 251001-1837 - Fix for rare Stereo recording filename issue # 251020-0835 - Added code for recording_dtmf_muting, fix for stereo call recording +# 260902-1607 - Fix for systems with overloaded Khomp servers # $script = 'agi-VDAD_ALL_outbound.agi'; @@ -7216,6 +7217,14 @@ sub khomp_json_api $agi_string = "-- KHOMP RESPONSE JSON: |$message|"; &agi_output; } + $test503 = $message; + $test503 =~ s/\n|\r|\t//gi; + if ($test503 =~ /503 Service Not Available/) + { + $agi_string = "-- KHOMP API REJECTED OUR REQUEST!!! forcing fake timeout response"; &agi_output; + $message = '{"id":0,"jsonrpc":"2.0","result":{"calls":[{"disconnected":false,"fields":{"analyzer_action":"Connect","analyzer_conclusion":"Khomp Reject","analyzer_pattern":"","analyzer_stamp":"9999999999","answer_stamp":"9999999999","audio_stamp":"9999999999","end_stamp":"","hangup_cause":"","hangup_cause_sent":"","hangup_origin":"","sip_header:call-id":"","start_stamp":"1788358771462"}}]}}'; + } + #UC# $json = JSON::PP->new->ascii->pretty->allow_nonref; #UC# $result = $json->decode($message); diff --git a/bin/FastAGI_log.pl b/bin/FastAGI_log.pl index 9e1dddc9..9a023460 100644 --- a/bin/FastAGI_log.pl +++ b/bin/FastAGI_log.pl @@ -107,6 +107,7 @@ # 260327-0824 - Fixes for PJSIP compatibility # 260424-1644 - Fix for rare Auto-Alt Dial issue # 260515-1936 - Added internal logging +# 260902-1608 - Fix for systems with overloaded Khomp servers # # defaults for PreFork @@ -3847,6 +3848,13 @@ sub khomp_json_api $agi_string = "-- KHOMP JSON : |$khomp_json|"; &agi_output; $agi_string = "-- KHOMP RESPONSE JSON: |$message|"; &agi_output; } + $test503 = $message; + $test503 =~ s/\n|\r|\t//gi; + if ($test503 =~ /503 Service Not Available/) + { + $agi_string = "-- KHOMP API REJECTED OUR REQUEST!!! forcing fake timeout response"; &agi_output; + $message = '{"id":0,"jsonrpc":"2.0","result":{"calls":[{"disconnected":false,"fields":{"analyzer_action":"Connect","analyzer_conclusion":"Khomp Reject","analyzer_pattern":"","analyzer_stamp":"9999999999","answer_stamp":"9999999999","audio_stamp":"9999999999","end_stamp":"","hangup_cause":"","hangup_cause_sent":"","hangup_origin":"","sip_header:call-id":"","start_stamp":"1788358771462"}}]}}'; + } #UC# $json = JSON::PP->new->ascii->pretty->allow_nonref; #UC# $result = $json->decode($message); diff --git a/experimental/FastAGIServer/AGIHandlers/VDAD_ALL_outbound.pm b/experimental/FastAGIServer/AGIHandlers/VDAD_ALL_outbound.pm index 6e7df1c2..a6e4adda 100644 --- a/experimental/FastAGIServer/AGIHandlers/VDAD_ALL_outbound.pm +++ b/experimental/FastAGIServer/AGIHandlers/VDAD_ALL_outbound.pm @@ -136,7 +136,8 @@ package AGIHandlers::VDAD_ALL_outbound; # 251001-1837 - Fix for rare Stereo recording filename issue # 251020-0835 - Added code for recording_dtmf_muting, fix for stereo call recording # 260805-1057 - Converted to a PM file for the FastAGIServer system - +# 260902-1606 - Fix for systems with overloaded Khomp servers +# our $fagi_channel = ''; our $AGI = ''; @@ -7318,6 +7319,14 @@ sub khomp_json_api $agi_string = "-- KHOMP RESPONSE JSON: |$message|"; &agi_output; } + $test503 = $message; + $test503 =~ s/\n|\r|\t//gi; + if ($test503 =~ /503 Service Not Available/) + { + $agi_string = "-- KHOMP API REJECTED OUR REQUEST!!! forcing fake timeout response"; &agi_output; + $message = '{"id":0,"jsonrpc":"2.0","result":{"calls":[{"disconnected":false,"fields":{"analyzer_action":"Connect","analyzer_conclusion":"Khomp Reject","analyzer_pattern":"","analyzer_stamp":"9999999999","answer_stamp":"9999999999","audio_stamp":"9999999999","end_stamp":"","hangup_cause":"","hangup_cause_sent":"","hangup_origin":"","sip_header:call-id":"","start_stamp":"1788358771462"}}]}}'; + } + $json = JSON::PP->new->ascii->pretty->allow_nonref; $result = $json->decode($message);