gpt4 book ai didi

python - Asterisk 测试套件 : phone not ringing

转载 作者:行者123 更新时间:2023-12-01 05:43:41 25 4
gpt4 key购买 nike

我的extensions.conf为:

[users]
exten=>111,1,Dial(SIP/demo-alice,5)
exten=>111,n,UserEvent(TestResult,result:pass)
exten=>222,1,Dial(SIP/demo-bob,5)

可以了,电话可以互相拨号。在Python测试中:

df = ami.originate(
channel = "Local/222@users",
exten = "111",
priority = "1",
context = "users")

启动测试时,它失败并给我一个警告:

Unhandled error in Deferred:
Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/starpy/manager.py", line 153, in lineReceived
self.dispatchIncoming() # does dispatch and clears cache
File "/usr/lib/python2.7/dist-packages/starpy/manager.py", line 241, in dispatchIncoming
callback(message)
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 362, in callback
self._startRunCallbacks(result)
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 458, in _startRunCallbacks
self._runCallbacks()
--- <exception caught here> ---
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 545, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/usr/lib/python2.7/dist-packages/starpy/manager.py", line 347, in errorUnlessResponse
raise error.AMICommandFailure(message)
starpy.error.AMICommandFailure: {'message': 'Originate failed', 'response': 'Error', 'actionid': 'VirtATS3-36015280-2'}

通过 CLI 发起的工作正常:

channel originate Local/222@users extension 111@users

222响铃,接听电话后111开始响铃。

更新

弄清楚如何在 ami.originate() 中发送 SIP header 。找到here 。坏事是它不起作用 - 发起失败,就像上面记录的错误一样。在 dialplan 中发送 header 也不是解决方案。有什么帮助吗?

    df = ami.originate(
channel = "Local/222@users",
exten = "111",
priority = "1",
context = "users",
variable = {
"SIPAddHeader":"Call-Info: answer-after=0"
})

最佳答案

除非 channel 双方都得到应答,否则发起 AMI 操作将失败。您在这里有几个选择。您可以确保每个人都有答案,或者您可以处理原始失败(尽管您可能应该这样做以避免传播扭曲的异常):

def __handle_originate_failure(self, reason):
print "Originate failure: %s" % reason
return reason

df = ami.originate(
channel = "Local/222@users",
exten = "111",
priority = "1",
context = "users")
df.addErrback(__handle_originate_failure)

请注意,TestCase 类为 Originate 失败提供了一个默认处理程序 (handleOriginateFailure),该处理程序将自动失败并停止测试。如果您希望您的 Originate 始终成功,您可能需要使用它。

关于python - Asterisk 测试套件 : phone not ringing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16806444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com