Asterisk is not executing python file using AGI

1.4k Views Asked by At

Log of asterisk after call is as follows:

<SIP/AC_221-00000007>AGI Tx >> agi_channel: SIP/AC_221-00000007
<SIP/AC_221-00000007>AGI Tx >> agi_language: en
<SIP/AC_221-00000007>AGI Tx >> agi_type: SIP
<SIP/AC_221-00000007>AGI Tx >> agi_uniqueid: 1607606631.7
<SIP/AC_221-00000007>AGI Tx >> agi_version: 11.25.1
<SIP/AC_221-00000007>AGI Tx >> agi_callerid: 8097119191
<SIP/AC_221-00000007>AGI Tx >> agi_calleridname: unknown
<SIP/AC_221-00000007>AGI Tx >> agi_callingpres: 0
<SIP/AC_221-00000007>AGI Tx >> agi_callingani2: 0
<SIP/AC_221-00000007>AGI Tx >> agi_callington: 0
<SIP/AC_221-00000007>AGI Tx >> agi_callingtns: 0
<SIP/AC_221-00000007>AGI Tx >> agi_dnid: 2804
<SIP/AC_221-00000007>AGI Tx >> agi_rdnis: unknown
<SIP/AC_221-00000007>AGI Tx >> agi_context: OUTBOUND
<SIP/AC_221-00000007>AGI Tx >> agi_extension: 2804
<SIP/AC_221-00000007>AGI Tx >> agi_priority: 2
<SIP/AC_221-00000007>AGI Tx >> agi_enhanced: 1.0
<SIP/AC_221-00000007>AGI Tx >> agi_accountcode: 
<SIP/AC_221-00000007>AGI Tx >> agi_threadid: 140019575056128
<SIP/AC_221-00000007>AGI Tx >>  

I can also share the Dial plan and file which we are executing

exten => 2804,1,Answer()
exten => 2804,2,EAGI(/var/lib/asterisk/agi-bin/test.py)

Also I am sharing the code in my python file

#!/usr/bin/env python3
from asterisk.agi import *

agi = AGI()
agi.say_number("12345")
agi.verbose("python agi started ahead")

print("Hey")

Library installed Pyst2 for asterisk

1

There are 1 best solutions below

2
On

First of all you are dooing EAGI, which is NOT AGI.

Then you need probably check by tag other issues with AGI/python, for example this can be helpfull. How to use Asterisk AGI with python3? (more at https://stackoverflow.com/questions/tagged/agi+python)

AGI script in most cases run in very special environment under asterisk user, so you need double check you have library path.

For check for errors, stop asterisk, after that run it in console via

asterisk -vvvgc
agi set debug on

Now if you call it will show STDERROR from your script in console. By default it show on /dev/tty9