Fix AMI callback queue desynchronization causing dialer lockup under high call volume#66
Open
psycho84tr wants to merge 1 commit intoIssabelFoundation:masterfrom
Open
Conversation
Under high call volume, the AMI event processing in AMIClientConn can lock up the entire dialer due to three related issues: 1. wait_response() blocks indefinitely when an AMI response is lost or delayed, freezing the dialer event loop. Fix: Add a 30-second timeout so the dialer can recover. 2. Orphan AMI responses (no matching callback in queue) cause process_event() to return FALSE, breaking the event chain. Fix: Log a warning and return TRUE to continue processing. 3. When a queued request has not been sent yet but a response arrives, the handler assignment fails silently. Fix: Skip the unsent request, send the next one, and continue. Additionally, in AMIEventProcess, _ejecutarOriginate() crashes with "Call to a member function asyncOriginate() on a non-object" when the AMI connection is not yet established after a process restart. Fix: Add a NULL check for $this->_ami before calling marcarLlamada(). These fixes prevent the dialer from freezing during high-volume outbound campaigns and allow graceful recovery from AMI communication glitches without requiring a manual restart.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Under high outbound call volume, the dialer can lock up completely due to a race condition in AMI (Asterisk Manager Interface) callback queue processing. This affects production systems running predictive/progressive dialer campaigns and requires a manual restart to recover.
Root Cause
Three related issues in
AMIClientConn.class.php:wait_response()infinite loop — When an AMI response is lost or delayed, the synchronous wait loop blocks indefinitely, freezing the entire dialer event loop.Orphan responses break the event chain — AMI responses arriving without a matching callback in
_queue_requestscauseprocess_event()to returnFALSE, halting event processing.Unsent request queue mismatch — When a queued request hasn't been sent yet but a response arrives for a different request, the handler assignment fails silently.
Additionally,
AMIEventProcess.class.phpcrashes with a PHP Fatal Error (Call to a member function asyncOriginate() on a non-object) when_ejecutarOriginate()is called before the AMI connection is established after a process restart.Changes
AMIClientConn.class.php:wait_response()to prevent indefinite blockingTRUEto continue processing)AMIEventProcess.class.php:NULLcheck for$this->_amiin_ejecutarOriginate()before callingmarcarLlamada()Symptoms (before fix)
segundo Response sobreescribe primer Responseandse pierde respuesta porque no hay callback encoladoTesting
Made with Cursor