Agi debug error : Connection reset by peer

Hello, and thanks for help :

I am running Asterisk 1.8.8 on Amazon Linux AMI 2012.09.1 (Linux 3.2).

I have installed PHPAGI 2.2 on a remote server with xinetd and looks working :

ubuntu@ip-10-243-114-220:~$ sudo telnet 54.243.xxx.xxx 4573
Trying 54.243.xxx.xxx...
Connected to 54.243.xxx.xxx.
Escape character is '^]'.
Connection closed by foreign host.
ubuntu@ip-10-243-114-220:~$

when, from my asterisk box i try to call :

exten => _X.,1, Agi(agi://54.243.xxx.xxx:4573/a_sample.php)

where the file ‘sample.php’ contain only 1 line of code:

$fastagi->hungup('cool, the FastAGI server has been called!');

i get on my asterisk cli after a ‘agi set debug on’

a bounch of errors:

 == Using SIP RTP CoS mark 5
    -- Executing [2580@from-internal:1] AGI("SIP/2133-00000040", "agi://54.243.xxx.xxx:4573/a_sample.php") in new stack
AGI Tx >> agi_network: yes
AGI Tx >> agi_network_script: a_sample.php
<SIP/2133-00000040>AGI Tx >> agi_request: agi://54.243.xxx.xxx:4573/a_sample.php
<SIP/2133-00000040>AGI Tx >> agi_channel: SIP/2133-00000040
<SIP/2133-00000040>AGI Tx >> agi_language: en
<SIP/2133-00000040>AGI Tx >> agi_type: SIP
<SIP/2133-00000040>AGI Tx >> agi_uniqueid: 1363713052.64
<SIP/2133-00000040>AGI Tx >> agi_version: 1.8.8.1
<SIP/2133-00000040>AGI Tx >> agi_callerid: 2133
<SIP/2133-00000040>AGI Tx >> agi_calleridname: unknown
<SIP/2133-00000040>AGI Tx >> agi_callingpres: 0
<SIP/2133-00000040>AGI Tx >> agi_callingani2: 0
<SIP/2133-00000040>AGI Tx >> agi_callington: 0
<SIP/2133-00000040>AGI Tx >> agi_callingtns: 0
<SIP/2133-00000040>AGI Tx >> agi_dnid: 2580
<SIP/2133-00000040>AGI Tx >> agi_rdnis: unknown
[Mar 19 17:10:52] ERROR[10000]: utils.c:1164 ast_carefulwrite: write() returned error: Connection reset by peer
<SIP/2133-00000040>AGI Tx >> agi_context: from-internal
[Mar 19 17:10:52] ERROR[10000]: utils.c:1164 ast_carefulwrite: write() returned error: Broken pipe
<SIP/2133-00000040>AGI Tx >> agi_extension: 2580
[Mar 19 17:10:52] ERROR[10000]: utils.c:1164 ast_carefulwrite: write() returned error: Broken pipe
<SIP/2133-00000040>AGI Tx >> agi_priority: 1
[Mar 19 17:10:52] ERROR[10000]: utils.c:1164 ast_carefulwrite: write() returned error: Broken pipe
<SIP/2133-00000040>AGI Tx >> agi_enhanced: 0.0
[Mar 19 17:10:52] ERROR[10000]: utils.c:1164 ast_carefulwrite: write() returned error: Broken pipe
<SIP/2133-00000040>AGI Tx >> agi_accountcode:
[Mar 19 17:10:52] ERROR[10000]: utils.c:1164 ast_carefulwrite: write() returned error: Broken pipe
<SIP/2133-00000040>AGI Tx >> agi_threadid: 139841764480768
[Mar 19 17:10:52] ERROR[10000]: utils.c:1164 ast_carefulwrite: write() returned error: Broken pipe
<SIP/2133-00000040>AGI Tx >>
[Mar 19 17:10:52] ERROR[10000]: utils.c:1164 ast_carefulwrite: write() returned error: Broken pipe
    -- <SIP/2133-00000040>AGI Script agi://54.243.203.90:4573/a_sample.php completed, returning 0

and the php code is not executed.

Pls, help.

You closed the connection without reading the parameters sent by Asterisk.

I’m not familiar with that AGI library, but I would be surprised if you didn’t have to instantiate an object, even if it turns out that doing so reads the initial parameters, so you don’t also have to do that explicitly.

Are you sure you actually need AGI? Quite a few people use it do do things that could have been done in the dialplan.

There isn’t a hungup method that I can see and hangup expects a channel name.

I see, but if in my agi script i write

i get also the same error.

About instantiating an object, that’s what reported in PhpAGI doc :

1. $fastagi is initialized as a new AGI. 2. The script determines which script was requested. 3. The script is called using reqire_once($fastagi->request['agi_request']). 4. Your script takes over. You must not create a new AGI, but insead use the $fastagi instance that has already been created.

But I agree:

but I don’know where i have to dig for the error: asterisk side? phpagi side? xinetd side?

I can’t use the documentation out of context.

I believe hungup should be hangup and reqire_once should be require_once.

Thank you david, but it doesn’t help me too much :frowning:

xinetd should reference phpagi-fastagi.php.

You should edit that to reference your script.

There may be ohter subtleties.

Actually, the name of your script is in the configuration file for the fastagi script.

The documentation, to save anyone else time, is at phpagi.sourceforge.net/phpagi22/ … i.php.html

xinetd debug says :

13/3/19@20:22:16: DEBUG: 9878 {server_start} Starting service fastagi
13/3/19@20:22:16: DEBUG: 9878 {main_loop} active_services = 1
13/3/19@20:22:16: DEBUG: 9879 {exec_server} duping 7
13/3/19@20:22:16: ERROR: 9879 {exec_server} execv( /home/ubuntu/phpagi/phpagi-fastagi.php ) failed: No such file or directory (errno = 2)
13/3/19@20:22:16: DEBUG: 9878 {main_loop} active_services = 1
13/3/19@20:22:16: DEBUG: 9878 {main_loop} select returned 1
13/3/19@20:22:16: DEBUG: 9878 {check_pipe} Got signal 17 (Child exited)
13/3/19@20:22:16: DEBUG: 9878 {child_exit} waitpid returned = 9879
13/3/19@20:22:16: DEBUG: 9878 {server_end} fastagi server 9879 exited

But path is correct: /home/ubuntu/phpagi/phpagi-fastagi.php .
It is correct!!! I swear !!!

So why??

Assuming there isn’t yet another typo, there appears to be a spurious space in the file name.


A spurious space?
Sorry but which one?
maybe i am so frustrated to make beginner mistakes :frowning:

A spurious space?
Sorry but which one?
maybe i am so frustrated to make beginner mistakes :frowning:

Hi ultimomiglio,

Edit your phpagi-fastagi.php and change first line interpreter command line php, with your real path.
You can see with “which php” in your command line.

In my case, was /usr/local/bin/php, but my php was in /usr/bin/php.
i changed and worked fine.

This post is older, but i write if someone need help with that.