Connection failed in asterisk CLI

php version: 5.3.10
Asterisk version: 1.8.22.0
System: Ubuntu
A2billing: 2.0.4

I am registering one customer of a2billing in softphone and dialing one number. In asterisk i am getting below result:

<SIP/myip-0000004c>AGI Tx >> 200 result=1 <SIP/myip-0000004c>AGI Rx << Connection failed <SIP/myip-0000004c>AGI Tx >> 510 Invalid or unknown command [Dec 30 07:59:16] ERROR[28331]: utils.c:1343 ast_carefulwrite: write() returned error: Broken pipe [Dec 30 07:59:16] ERROR[28331]: utils.c:1343 ast_carefulwrite: write() returned error: Broken pipe -- <SIP/myip-0000004c>AGI Script a2billing.php completed, returning 0

My /etc/asterisk/extconfig.conf have below data:

sipusers => mysql,a2billing14,cc_sip_buddies sippeers => mysql,a2billing14,cc_sip_buddies iaxusers => mysql,a2billing14,cc_iax_buddies iaxpeers => mysql,a2billing14,cc_iax_buddies voicemail => mysql,a2billing14,voicemail_users

My /etc/asterisk/res_config_mysql.conf have below data:

[a2billing14] dbhost = localhost dbname = a2billing14 dbuser = a2bdbuser dbpass = a2bdbpassw dbport = 3306 dbsock = /var/run/mysqld/mysqld.sock

My asterisk showing the below result on executing “realtime mysql status” command:

[quote]general connected to a2billing14@localhost, port 3306 with username a2bdbuser for 58 seconds.
a2billing14 connected to a2billing14@localhost, port 3306 with username a2bdbuser for 17 hours, 7 minutes.[/quote]

Does anyone know what is i am missing or what is the exact issue?

I am getting correct credential in AGI when it is trying to connect and using those credential i can connect in mysql but from CLI> i am getting connection failed error.

Thanks in advance.

The issue lies in the AGI script. The AGI script is not part of Asterisk.