简体   繁体   English

asterisk python agi问题

[英]asterisk python agi issue

i have basic python agi code with pyst lib as: 我有pyst lib的基本python agi代码:

extensions.conf extensions.conf文件

[from-internal]
exten => _.,1,answer()
exten => _.,2,AGI(test.py)

i have test.py in /var/lib/asterisk/agi-bin as 我在/ var / lib / asterisk / agi-bin中有test.py

#!/usr/bin/python
import sys
import os
from agi import AGI
def test_call(agi = None,text = ""):
    agi.say_alpha(text, "#")
    agi.hangup()
if __name__ == "__main__":
    text = 'abcdefr'
    agi = AGI()
    test_call(agi,text)

and i have one file agi.py which is get from pyst lib. 我有一个文件agi.py从pyst lib获取。

when i try to call to this agi i get this issue 当我试图打电话给这个agi我得到这个问题

Executing [123@from-internal:1] Answer("SIP/12345-00000016", "") in new stack
[Mar 14 00:01:29] NOTICE[2790]: res_rtp_asterisk.c:2358 ast_rtp_read: Unknown RTP codec 126 received from '169.254.38.82:20338'
    -- Executing [123@from-internal:2] AGI("SIP/12345-00000016", "test.py") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/test.py
 test.py: Failed to execute '/var/lib/asterisk/agi-bin/test.py': No such file or directory
    -- Auto fallthrough, channel 'SIP/12345-00000016' status is 'UNKNOWN'
    -- Executing [h@from-internal:1] Hangup("SIP/12345-00000016", "") in new stack
  == Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/12345-00000016'

i see that i have this file in /var/lib/asterisk/agi-bin which 777 permission. 我看到我在/ var / lib / asterisk / agi-bin中有777权限。

Please suggest to get this basic script work. 请建议让这个基本脚本工作。

thank all in advance 先谢谢大家

There can be 2 reason for such error: 这种错误可能有两个原因:

  1. no file /var/lib/asterisk/agi-bin/test.py in that location or it not accessable by asterisk for some reason - linux general permission issue. 在该位置没有文件/var/lib/asterisk/agi-bin/test.py或由于某种原因它不能由星号访问 - linux一般权限问题。
  2. file /var/lib/asterisk/agi-bin/test.py, but no some libraries(python give same error). 文件/var/lib/asterisk/agi-bin/test.py,但没有一些库(python给出相同的错误)。 This one is more likly. 这个更有可能。 Try execute script manual from asterisk user and see what it say. 尝试从asterisk用户执行脚本手册,看看它的内容。

Recomendation: Use FastAGI instead of AGI. Recomendation:使用FastAGI代替AGI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM