我已经使用思科适配器配置了模拟本地电话,因此我可以从SIP电话拨打任何出站电话。但是我无法通过 AMI 实现这一点,AMI 通过中继调用出站通道然后播放提示。
manager.conf
:
[asteriskjava]
secret = asteriskjava
deny = 0.0.0.0/0.0.0.0
permit = 127.0.0.1/255.255.255.0
read = all
write = all
extensions.conf
:
[bulk]
exten => 8,1,Playback(thank-you-cooperation)
exten => h,1,Hangup
source code
:
public class HelloManager
{
private ManagerConnection managerConnection;
public HelloManager() throws IOException
{
ManagerConnectionFactory factory = new ManagerConnectionFactory(
"localhost", "asteriskjava", "asteriskjava");
this.managerConnection = factory.createManagerConnection();
}
public void run() throws IOException, AuthenticationFailedException,
TimeoutException
{
OriginateAction originateAction;
ManagerResponse originateResponse;
originateAction = new OriginateAction();
originateAction.setChannel("SIP/405/7000000");
originateAction.setContext("bulk");
originateAction.setExten("8");
originateAction.setPriority(new Integer(1));
originateAction.setAsync(true);
// connect to Asterisk and log in
managerConnection.login();
// send the originate action and wait for a maximum of 30 seconds for Asterisk
// to send a reply
originateResponse = managerConnection.sendAction(originateAction, 30000);
// print out whether the originate succeeded or not
System.out.println("---" + originateResponse.getResponse());
// and finally log off and disconnect
managerConnection.logoff();
}
}
其中405
是用于传出呼叫的 CISCO 适配器的用户 ID,7000000
是示例手机号码。
以下是日志:
== Manager 'asteriskjava' logged on from 127.0.0.1
== Manager 'asteriskjava' logged off from 127.0.0.1
== Using SIP RTP CoS mark 5
> Channel SIP/405-0000000c was answered.
-- Executing [8@bulk:1] Playback("SIP/405-0000000c", "thank-you-cooperation") in new stack
-- <SIP/405-0000000c> Playing 'thank-you-cooperation.gsm' (language 'en')
-- Auto fallthrough, channel 'SIP/405-0000000c' status is 'UNKNOWN'
-- Executing [h@bulk:1] Hangup("SIP/405-0000000c", "") in new stack
== Spawn extension (bulk, h, 1) exited non-zero on 'SIP/405-0000000c'
我认为SIP/405
正在回答,执行Playback
然后挂断,而不是重定向到样本编号。
有什么建议吗?
编辑:如何配置我的思科适配器以重定向传出呼叫,而不是应答和建立网桥?
已在 ATA 上配置振铃、应答和忙识别。
星号按照您的要求工作,据我从您的踪迹中看到。
如果适配器未调用,则请检查您的适配器设置。例如,它可以是用音调调用,为什么你线期望它是脉冲。
也可能是任务的适配器类型不正确。要通过PSTN线路呼叫,您需要FXO适配器,而不是FXS。