Closed chopsywa closed 7 months ago
easy way to debug your AGI is to "php /var/lib/asterisk/agi-bin/steerInbound.php" and confirm it executes properly. It may be some issue due to php compatibility . 17 is using PHP 8.2 which is too strict.
I've done this. It runs fine from the command line. I can't get any info in, or out of the AGI object obviously as it's not in scope, but there is no runtime error.
php -l shows no syntax errors and when I run the command off the command line, my rest calls return a valid result using one of my test numbers embedded in the script.
I don't think the script is failing. I just don't think the script ever runs.
I just made this script
#!/usr/bin/php -q
<?php
// set up AGI env
include("phpagi.php");
$AGI = new AGI();
$AGI->verbose("Hello world");
?>
and I get the same result.
Regards
Mark Dutton
Hi @chopsywa are you saying no AGI script is running for you?
May be try to check any open source module AGI script if that can give you some idea?
As this issue is specific to your script so requesting you to please take help from the community.
I don't think it is specific to my script. As you can see above, I made a script that simply instantiates the AGI object and creates verbose output of a fixed string and this does not run either. No open source script will be simpler than this.
It works fine on v16, so I am not sure what I will get from the community. Isn't John Fawcett maintaining dynamic routes for v17? I will post in the community and see what comes back.
okay i am testing your script on my system, will let you know the result asap.
Its working fine for me.
Steps I followed -
1) Copy your AGI to Asterisk AGI folder with asterisk permissions. (Note permission has be asterisk:asterisk) `root@vultr:/var/lib/asterisk/agi-bin# cat testphp.php
<?php
// set up AGI env include("phpagi.php"); $AGI = new AGI();
$AGI->verbose("Hello world");
?> `
2) Created dialplan to trigger the AGI
root@vultr:/etc/asterisk# cat extensions_custom.conf exten => 8123322572,1,Answer() same => n,AGI(testphp.php) same => n,Hangup()
3) See the Asterisk logs of AGI triggered during the call -
`vultr*CLI> == Using SIP RTP Audio TOS bits 184 == Using SIP RTP Audio TOS bits 184 in TCLASS field. == Using SIP RTP Audio CoS mark 5 -- Executing [8123322572@from-internal:1] Answer("PJSIP/2001-00000004", "") in new stack
0x7fa6b805e460 -- Strict RTP learning after remote address set to: 10.204.0.199:39346 -- Executing [8123322572@from-internal:2] AGI("PJSIP/2001-00000004", "testphp.php") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/testphp.php <PJSIP/2001-00000004>AGI Tx >> agi_request: testphp.php <PJSIP/2001-00000004>AGI Tx >> agi_channel: PJSIP/2001-00000004 <PJSIP/2001-00000004>AGI Tx >> agi_language: en <PJSIP/2001-00000004>AGI Tx >> agi_type: PJSIP <PJSIP/2001-00000004>AGI Tx >> agi_uniqueid: 1714469509.4 <PJSIP/2001-00000004>AGI Tx >> agi_version: 21.0.2 <PJSIP/2001-00000004>AGI Tx >> agi_callerid: 2001 <PJSIP/2001-00000004>AGI Tx >> agi_calleridname: Ext-2001 <PJSIP/2001-00000004>AGI Tx >> agi_callingpres: 0 <PJSIP/2001-00000004>AGI Tx >> agi_callingani2: 0 <PJSIP/2001-00000004>AGI Tx >> agi_callington: 0 <PJSIP/2001-00000004>AGI Tx >> agi_callingtns: 0 <PJSIP/2001-00000004>AGI Tx >> agi_dnid: 8123322572 <PJSIP/2001-00000004>AGI Tx >> agi_rdnis: unknown <PJSIP/2001-00000004>AGI Tx >> agi_context: from-internal <PJSIP/2001-00000004>AGI Tx >> agi_extension: 8123322572 <PJSIP/2001-00000004>AGI Tx >> agi_priority: 2 <PJSIP/2001-00000004>AGI Tx >> agi_enhanced: 0.0 <PJSIP/2001-00000004>AGI Tx >> agi_accountcode: <PJSIP/2001-00000004>AGI Tx >> agi_threadid: 140353988445888 <PJSIP/2001-00000004>AGI Tx >> 0x7fa6b805e460 -- Strict RTP qualifying stream type: audio <PJSIP/2001-00000004>AGI Rx << VERBOSE "Hello world" 1 testphp.php: Hello world <PJSIP/2001-00000004>AGI Tx >> 200 result=1 -- <PJSIP/2001-00000004>AGI Script testphp.php completed, returning 0 -- Executing [8123322572@from-internal:3] Hangup("PJSIP/2001-00000004", "") in new stack
`
Not seeing any issue with the normal AGI in the system, now not sure if its your system or triggering from dynroute module is having some issue.
My testing agrees with @kguptasangoma, no issues with AGI for me.
@chopsywa are you working in a Windows environment? If so, it's critically important in AGI files for the EOL end of line chars to be UNIX style (LF) not windows (CRLF).
A difference in testing is that FreePBX itself is executing using its FastAGI execution method, and not directly.
I'm doing everything in Linux via CLI with Nano. I don't think AGI itself is the issue. It's the dynamic-routes module that calls the AGI system. I tried to use that same line in my extensions_custom.conf file and it doesn't work for me, but I am not advanced enough in the dialplan syntax. I have this single line in my extensions.conf file that I have added initially through CLI, but now looking at it through freepbx web interface. exten => 121,1,Answer() same => n,AGI(test.php) same => n,Hangup()
I just get a "number is not in service error". I suspect I am supposed to add a context? I am sure it would work for me too if I got the dialplan entry right, but I am trying to use the dynamic routes module, where I select agi from the dropdown and the fullpath of the script in the AGI Lookup field.
OK. I copied the script from the screen and pasted into Notepad++ and it appears that Nano uses crlf. I converted the eol to Unix style and pasted back with vi and this made my 2 line file work.
@lgaetz you were on the money. The scripts did indeed have CRLF. I scp'd them back to Windows and stripped the CR with Notepad++ and copied back to Linux and they worked. I have to say now I am not sure if I had at some point copied and pasted from Linux into Windows Notepad++ and then copied back again. If I don't specifically tell Notepad++ to treat lines as Linux, it will put a CRLF on the end even when they are pasted directly from a putty session.
PHP always worked from the command line.
Thank you for helping here and to @kguptasangoma as well. I feel sorta bad for engaging you both on this, but on the upside, I did find an issue in the dynamic routes page which is a bug (missing description field in issue #6).
I have a PHP script called using AGI. On v16 it works perfectly. On v17 (Edge version), the script never runs (I have some embedded AGI-verbose lines embedded. If I run with agi debug on, I get the following output when I instigate the script by dialing the dynamic route extension.
dump exec set show pbxCLI> agi set debug on AGI Debugging Enabled AGI Tx >> agi_network: yes AGI Tx >> agi_network_script: /var/lib/asterisk/agi-bin/steerInbound.php <PJSIP/101-0000001d>AGI Tx >> agi_request: agi://127.0.0.1//var/lib/asterisk/agi-bin/steerInbound.php <PJSIP/101-0000001d>AGI Tx >> agi_channel: PJSIP/101-0000001d <PJSIP/101-0000001d>AGI Tx >> agi_language: en_AU <PJSIP/101-0000001d>AGI Tx >> agi_type: PJSIP <PJSIP/101-0000001d>AGI Tx >> agi_uniqueid: 1714459833.37 <PJSIP/101-0000001d>AGI Tx >> agi_version: 21.0.2 <PJSIP/101-0000001d>AGI Tx >> agi_callerid: 101 <PJSIP/101-0000001d>AGI Tx >> agi_calleridname: Mark Dutton <PJSIP/101-0000001d>AGI Tx >> agi_callingpres: 0 <PJSIP/101-0000001d>AGI Tx >> agi_callingani2: 0 <PJSIP/101-0000001d>AGI Tx >> agi_callington: 0 <PJSIP/101-0000001d>AGI Tx >> agi_callingtns: 0 <PJSIP/101-0000001d>AGI Tx >> agi_dnid: *100 <PJSIP/101-0000001d>AGI Tx >> agi_rdnis: unknown <PJSIP/101-0000001d>AGI Tx >> agi_context: dynroute-1 <PJSIP/101-0000001d>AGI Tx >> agi_extension: s <PJSIP/101-0000001d>AGI Tx >> agi_priority: 2 <PJSIP/101-0000001d>AGI Tx >> agi_enhanced: 0.0 <PJSIP/101-0000001d>AGI Tx >> agi_accountcode: <PJSIP/101-0000001d>AGI Tx >> agi_threadid: 139654043944640 <PJSIP/101-0000001d>AGI Tx >> <PJSIP/101-0000001d>AGI Rx << Exception: Zend Extension "/var/lib/asterisk/agi-bin/steerInbound.php" does not exist <PJSIP/101-0000001d>AGI Tx >> 510 Invalid or unknown command <PJSIP/101-0000001d>AGI Tx >> HANGUP pbxCLI>
I am wondering if the bolded line is correct.
The script is error free and works on v16 as is.
Script is here.
The dynamic routing page components pertaining to the script look like this.