#17 AGI_AsteriskManager callback hangs if called too many times

open
nobody
None
5
2010-06-10
2010-06-10
No

Hello,
I have written a small proof of concept php standalone script connecting to asterisk using the AGI_AsteriskManager interface and setting few events handler functions:

$as = new AGI_AsteriskManager();
$res = $as->connect();
if ($res) {
$as->add_event_handler('Newchannel', 'newchannel_event');
$as->add_event_handler('Newstate', 'newstate_event');
$as->add_event_handler('Hangup', 'hangup_event');
$as->add_event_handler('Bridge', 'bridge_event');
$as->add_event_handler('Unlink', 'unlink_event');
$as->add_event_handler('VarSet', 'varset_event');
}

Each function does almost nothing, just echoes on the screen an "IN" and an "OUT"

function varset_event($ecode, $data, $server, $port){

echo "IN varset_event";
echo "OUT varset_event";

}

If I submit to asterisk 100 calls with 1 second of delay, all works perfectly.

If I submit to asterisk 100 calls at once, after few iterations, the script hangs with 100% CPU without doing nothing. strace-ing the script reports no activity.

Any ideas?

Leandro

Discussion

  • Leandro Dardini

    Leandro Dardini - 2010-06-10

    I removed the event handler binding and just stay connected while the 100 calls at once are made. The script hangs the same way. So it has to be something in the way the connection between the script and asterisk is managed.

     
  • Leandro Dardini

    Leandro Dardini - 2010-07-10

    I find the source of the problem. When too many calls are received, asterisk manager drops the connection with the client. The client gets stuck in an endless and tight loop trying to read from a closed socket. I just add a "die" when this happens, managing the restart of the application at higher level.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks