要從一個來自星號的出站呼叫,我想使用星號-java庫。我收到了拒絕連接異常(接近問題結尾)。使用AsteriskNOW,從Dongle撥出給出 - java.net.ConnectException:連接被拒絕
try {
factory = new ManagerConnectionFactory("127.0.0.1", "loginFromManagerConf", "passwordFromManagerConf");
outgoingCallManager = factory.createManagerConnection();
outgoingCallManager.login();
originateAction = new OriginateAction();
originateAction.setChannel("Dongle/dongle0/+91XXXXXXXXXX");
originateAction.setContext("dongle-outgoing");
// originateAction.setExten("1300");
originateAction.setPriority(new Integer(1));
originateAction.setTimeout(new Integer(30000));
} catch (IllegalStateException e) {
e.printStackTrace();
System.out.println("Unable to connect to Asterisk");
System.exit(0);
} catch (IOException e) {
e.printStackTrace();
System.out.println("Unable to connect to Asterisk");
System.exit(0);
} catch (AuthenticationFailedException e) {
e.printStackTrace();
System.out.println("Unable to connect to Asterisk");
System.exit(0);
} catch (TimeoutException e) {
e.printStackTrace();
System.out.println("Unable to connect to Asterisk");
System.exit(0);
}
在junit測試用例中調用上述內容時,eclipse沒有以root身份運行。
我已經在Ubuntu 12.04上安裝了AsteriskNOW。來電和短信正在工作。 chan-dongle不支持來電時的DTMF,但這是一個單獨的問題。基本上傳入工作很好。
Dongle.conf
context=dongle-incoming
Manager.conf
[loginFromManagerConf]
secret = passwordFromManagerConf
read=system,call,log,verbose,agent,command,user
write=system,call,log,verbose,agent,command,user
的extensions.conf
[dongle-outgoing]
exten => s,1,Playback(digits/2)
exten => s,n,Hangup()
[dongle-incoming]
exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${SMS})
exten => sms,n,System(java -classpath mypath -jar myjarfile ${CALLERID(num)} ${SMS})
exten => sms,n,Hangup()
exten => ussd,1,Verbose(Incoming USSD: ${USSD})
exten => ussd,n,System(echo '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${DONGLE}: ${USSD}' >> /var/log/asterisk/ussd.txt)
exten => ussd,n,Hangup()
exten => s,1,Answer()
exten => s,2,WaitExten()
exten => 123,1,Playback(digits/2)
exten => 234,1,Playback(digits/3)
exten => 345,1,Playback(digits/4)
exten => s,n,Goto(1)
異常
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:546)
at org.asteriskjava.util.internal.SocketConnectionFacadeImpl.<init>(SocketConnectionFacadeImpl.java:69)
at org.asteriskjava.manager.internal.ManagerConnectionImpl.createSocket(ManagerConnectionImpl.java:713)
at org.asteriskjava.manager.internal.ManagerConnectionImpl.connect(ManagerConnectionImpl.java:692)
at org.asteriskjava.manager.internal.ManagerConnectionImpl.doLogin(ManagerConnectionImpl.java:485)
at org.asteriskjava.manager.internal.ManagerConnectionImpl.login(ManagerConnectionImpl.java:433)
at org.asteriskjava.manager.internal.ManagerConnectionImpl.login(ManagerConnectionImpl.java:418)
at org.asteriskjava.manager.DefaultManagerConnection.login(DefaultManagerConnection.java:266)
at test.com.mcruiseon.ivr.OutgoingCallTest.test(OutgoingCallTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
NetStat輸出
[email protected]:/var/lib/asterisk/sounds/en$ sudo netstat -anp | grep asterisk
tcp 0 0 0.0.0.0:2000 0.0.0.0:* LISTEN 2892/asterisk
udp 0 0 0.0.0.0:5000 0.0.0.0:* 2892/asterisk
udp 0 0 0.0.0.0:4520 0.0.0.0:* 2892/asterisk
udp 0 0 0.0.0.0:5060 0.0.0.0:* 2892/asterisk
udp 0 0 0.0.0.0:4569 0.0.0.0:* 2892/asterisk
unix 2 [ ACC ] STREAM LISTENING 21312 2892/asterisk /var/run/asterisk/asterisk.ctl
管理器界面未啓用 - 如果是,星號將在端口5038上偵聽。 –
您是否可以添加manager.conf的[general]部分,所有未被評論的,如果綁定了一個掩碼IP – mirkobrankovic
謝謝,這工作。 – Siddharth