简体   繁体   中英

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.

It is my understanding that I can create an outgoing call event using the Asterisk Manager. To do this I have been trying to use the Python 'pyst' library.

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.

Has anyone written a script to do this in python?

I am only familiar with the Python language so solutions in other languages wouldn't be very helpful for me!

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

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. If you are realy "familar" with python, i recommend you read source of originate method and check what it send with asterisk doc

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. First you need read asterisk book.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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