开发者社区> 问答> 正文

Asterisk Call Manager/3.1.0'.:报错 

asterisk-java ami Unsupported protocol version 'Asterisk Call Manager/3.1.0'.:报错 

各位网友大家好,我在运行asterisk-java官网例子时出现错误。
asterisk服务器ip地址:192.168.1.171
manager.conf文件配合为:


[general] enabled = yes port = 5038 bindaddr = 0.0.0.0

[manager] secret=password permit=0.0.0.0/0.0.0.0 read=system,call,log,verbose,agent,command,user write=system,call,log,verbose,agent,command,user


使用telnet命令访问没有问题。
在另一个windows电脑上使用Eclipse创建工程,导入包:asterisk-java-1.0.0-m1.jar
拷贝asterisk-java官网例子,HelloManager.java,并修改访问ip和用户密码,代码如下:


import java.io.IOException;

import org.asteriskjava.manager.AuthenticationFailedException; import org.asteriskjava.manager.ManagerConnection; import org.asteriskjava.manager.ManagerConnectionFactory; import org.asteriskjava.manager.TimeoutException; import org.asteriskjava.manager.action.OriginateAction; import org.asteriskjava.manager.response.ManagerResponse;

public class HelloManager {     private ManagerConnection managerConnection;

    public HelloManager() throws IOException     {         ManagerConnectionFactory factory = new ManagerConnectionFactory(                 "192.168.1.171", "manager", "password");         this.managerConnection = factory.createManagerConnection();     }

    public void run() throws IOException, AuthenticationFailedException,             TimeoutException     {         OriginateAction originateAction;         ManagerResponse originateResponse;         // connect to Asterisk and log in                 originateAction = new OriginateAction();         originateAction.setChannel("SIP/1001");         originateAction.setContext("default");         originateAction.setExten("1300");         originateAction.setPriority(new Integer(1));         originateAction.setTimeout(new Long(30000));

        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();     }

    public static void main(String[] args) throws Exception     {         HelloManager helloManager;

        helloManager = new HelloManager();         helloManager.run();     } }


Eclipse编译运行:出现如下错误:
十二月 10, 2016 1:41:12 下午 org.asteriskjava.manager.internal.ManagerConnectionImpl connect 信息: Connecting to 192.168.1.171:5038 十二月 10, 2016 1:41:12 下午 org.asteriskjava.manager.internal.ManagerConnectionImpl setProtocolIdentifier 信息: Connected via Asterisk Call Manager/3.1.0 十二月 10, 2016 1:41:12 下午 org.asteriskjava.manager.internal.ManagerConnectionImpl setProtocolIdentifier 警告: Unsupported protocol version 'Asterisk Call Manager/3.1.0'. Use at your own risk. 十二月 10, 2016 1:41:13 下午 org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin 信息: Successfully logged in 十二月 10, 2016 1:41:13 下午 org.asteriskjava.manager.internal.EventBuilderImpl buildEvent 信息: No event class registered for event type 'fullybooted', attributes: {lastreload=4340, privilege=system,all, event=FullyBooted, uptime=4340, status=Fully Booted} 十二月 10, 2016 1:41:13 下午 org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin 信息: Determined Asterisk version: Asterisk 1.0 Error 十二月 10, 2016 1:41:13 下午 org.asteriskjava.manager.internal.ManagerConnectionImpl disconnect 信息: Closing socket. 十二月 10, 2016 1:41:13 下午 org.asteriskjava.manager.internal.ManagerReaderImpl run 信息: Terminating reader thread: No more lines available: null
请各位朋友帮帮忙,感激不尽。

展开
收起
kun坤 2020-06-08 12:16:33 486 0
1 条回答
写回答
取消 提交回答
  • 已自己解决。
    查考网站1:http://stackoverflow.com/questions/21602696/how-to-make-outbound-calls-in-asterisknow-using-asterisk-ami-with-java
    查考网站2:http://stackoverflow.com/questions/3010830/asterisk-manager-api-sippeers-permission-denied
    问题病症:不知道眼睛从那里看到manager.conf配置文件read和write需要那么写,自找的麻烦。
    修改:
    read = all
    write = all
    也可以发送如下ami命令直接去测试ami server有没有配置合适。
    Action: Originate Channel: SIP/1002     //对应sip.conf中配置的通道 Exten: 1002 Context: internal        //对应extension.conf中的internal Priority: 1 Callerid: 1003 Async: yes
    如果可以在1002分机显示1003号码来电,则证明ami server配置已经ok!!

    2020-06-08 12:16:39
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Taking-Windows-10-Kernel-Exploitation-To-The-Next-Level–Leveraging-Write-What-Where-Vulnerabilities-In-Creators-Update 立即下载
Well-That-Escalated-Quickly-How-Abusing-The-Docker-API-Led-To-Remote-Code-Execution-Same-Origin-Bypass-And-Persistence 立即下载
Cloak-And-Dagger-From-Two-Permissions-To-Complete-Control-Of-The-UI-Feedback-Loop 立即下载