本文介绍了Asterisk 没有使用 AGI 执行 python 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用后的星号日志如下:

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)

我也在我的 python 文件中共享代码

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")

库为星号安装了 Pyst2

Library installed Pyst2 for asterisk

推荐答案

首先你要做的是 EAGI,它不是 AGI.

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

然后您可能需要通过标记其他问题与 AGI/python 来检查,例如这可能会有所帮助.如何在 python3 中使用 Asterisk AGI?(更多信息请见 https://stackoverflow.com/questions/tagged/agi+python)

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 脚本在大多数情况下在 asterisk 用户下运行在非常特殊的环境中,因此您需要仔细检查您是否拥有库路径.

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

现在,如果您调用它,它将在控制台中显示您脚本中的 STDERROR.默认情况下它显示在/dev/tty9

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

这篇关于Asterisk 没有使用 AGI 执行 python 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-24 16:17