HELP! broken pipe error in agi script

Hello good day,

I am new to agi scripting. I am doing a project on asterisk 1.6 and sugarcrm integration. I want to access the sugarCRM database through AGI, i tried using the script below but it seems there’s a problem in accessing the sugarCRM… please help, any ideas why this doesn’t work?

phpscript,php

#!/usr/bin/php -q

<?php session_start(); set_time_limit(30); require('phpagi.php'); error_reporting(E_ALL); $agi = new AGI(); $agi->answer(); $callernumber = $agi->request["agi_callerid"]; $callername = $agi->request["agi_calleridname"]; $agi->say_digits($callernumber); $agi->verbose("****************************mysql start***************************************",1); $openDB = mysql_connect("http://localhost","root","")or die('Cannot connect to database!!!'); mysql_select_db("sugarcrm", $openDB); $agi->verbose("****************************mysql start22222***************************************",1); ?>

extensions.conf
exten => 3000,1,AGI(phpscript.php)
exten => 3000,2,Dial(SIP/3000,30)
exten => 3000,n,Hangup

output in cli
phpscript.php: AGI Request:
phpscript.php: Array
phpscript.php: (
phpscript.php: [agi_request] => phpscript.php
phpscript.php: [agi_channel] => SIP/3001-00000009
phpscript.php: [agi_language] => en
phpscript.php: [agi_type] => SIP
phpscript.php: [agi_uniqueid] => 1265770344.9
phpscript.php: [agi_version] => 1.6.0.20
phpscript.php: [agi_callerid] => 3001
phpscript.php: [agi_calleridname] => cha
phpscript.php: [agi_callingpres] => 0
phpscript.php: [agi_callingani2] => 0
phpscript.php: [agi_callington] => 0
phpscript.php: [agi_callingtns] => 0
phpscript.php: [agi_dnid] => 3000
phpscript.php: [agi_rdnis] => unknown
phpscript.php: [agi_context] => incoming
phpscript.php: [agi_extension] => 3000
phpscript.php: [agi_priority] => 1
phpscript.php: [agi_enhanced] => 0.0
phpscript.php: [agi_accountcode] =>
phpscript.php: [agi_threadid] => -1226949776
phpscript.php: )I>
phpscript.php:
phpscript.php: PHPAGI internal configuration:
phpscript.php: Array
phpscript.php: (
phpscript.php: [phpagi] => Array
phpscript.php: (
phpscript.php: [debug] => 1
phpscript.php: [error_handler] => 1
phpscript.php: [admin] => admin@myserver.host.com
phpscript.php: [hostname] => localhost.localdomain
phpscript.php: [tempdir] => /var/spool/asterisk/tmp
phpscript.php: )
phpscript.php: LI>
phpscript.php: [asmanager] => Array
phpscript.php: (
phpscript.php: [server] => localhost
phpscript.php: [port] => 5038
phpscript.php: [username] => root@localhost.localdomain
phpscript.php: [secret] => password
phpscript.php: )
phpscript.php:
phpscript.php: [fastagi] => Array
phpscript.php: (
phpscript.php: [setuid] => 1
phpscript.php: [basedir] => /var/lib/asterisk/agi-bin/
phpscript.php: )
phpscript.php:
phpscript.php: [festival] => Array
phpscript.php: (
phpscript.php: [text2wave] => /usr/bin/text2wave
phpscript.php: )
phpscript.php:
phpscript.php: [cepstral] => Array
phpscript.php: (
phpscript.php: [swift] => /usr/local/bin/swift
phpscript.php: [voice] => Allison-8kHz
phpscript.php: )
phpscript.php:
phpscript.php: )
phpscript.php:
[Feb 10 10:52:25] NOTICE[3870]: channel.c:2941 __ast_read: Dropping incompatible voice frame on SIP/3001-00000009 of format ulaw since our native format has changed to 0x2 (gsm)
phpscript.php: mysql start***********
[Feb 10 10:52:27] ERROR[3870]: utils.c:1019 ast_carefulwrite: write() returned error: Broken pipe
[Feb 10 10:52:27] ERROR[3870]: utils.c:1019 ast_carefulwrite: write() returned error: Broken pipe

can anyone please help?
i am using asterisk 1.6.0.20

thanks

You didn’t read standard input completely before exitting. When this happended to us, recently, it was due to leaving in debug code that wrote to standard output, and therefore provoked unexpected error responses from Asterisk.

Also try removing your verbose commands.