简体   繁体   English

使用 Asterisk Manager 和“pyst”创建拨出电话

[英]Creating an outgoing call using Asterisk Manager and “pyst”

I am trying to write some automation tests which make a phone call to my local Asterisk instance and then check that a receiving SIP client has received the call.我正在尝试编写一些自动化测试,这些测试向我的本地 Asterisk 实例拨打电话,然后检查接收 SIP 客户端是否已收到电话。

It is my understanding that I can create an outgoing call event using the Asterisk Manager.我的理解是我可以使用 Asterisk Manager 创建一个呼出事件。 To do this I have been trying to use the Python 'pyst' library.为此,我一直在尝试使用 Python 'pyst' 库。

I have not been able to find any working examples of how to implement this scenario.我还没有找到任何关于如何实现这个场景的工作示例。 From the information I have managed to gather, I have come up with this script:根据我设法收集的信息,我想出了这个脚本:

from asterisk import manager

HOST = 'localhost'
PORT = 5068

m = manager.Manager()

m.connect( HOST )

m.login( 'admin', 'temp123' )
targetURL = '441610000001'

response = m.originate(
    targetURL ,
    's',
    context='outgoing',
    priority='1'
    )

print m.status()

m.logoff()

m.close()

This script reports a 'success' response from Asterisk Manager but does not actually create an outgoing call.此脚本报告来自 Asterisk Manager 的“成功”响应,但实际上并未创建去电。

Has anyone written a script to do this in python?有没有人写过一个脚本来在 python 中做到这一点?

I am only familiar with the Python language so solutions in other languages wouldn't be very helpful for me!我只熟悉 Python 语言,所以其他语言的解决方案对我来说不是很有帮助!

Please read again documentation请再次阅读文档

"Targeturl" in your program actually have be channel, so in your code it have no channel type and host(if that sip).您程序中的“Targeturl”实际上是通道,因此在您的代码中它没有通道类型和主机(如果是 sip)。

Valid examples are:有效的例子是:

 targetURL = 'SIP/441610000001@myprovider_name'
 targetURL = 'Local/441610000001@outbound_context'

Context "outbound" have be valid and have deliver call.上下文“出站”已有效并已传递呼叫。

PYST is opensource framework. PYST 是开源框架。 If you are realy "familar" with python, i recommend you read source of originate method and check what it send with asterisk doc如果您真的“熟悉”python,我建议您阅读原始方法的源代码并使用星号文档检查它发送的内容

http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+Originate http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+Originate

Note: it is very bad idea program for asterisk using framework like PYST if you have no general knowledge about asterisk itself.注意:如果您对星号本身没有一般知识,那么使用像 PYST 这样的框架来编写星号是非常糟糕的主意。 First you need read asterisk book.首先你需要阅读星号书。

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

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