我是 FreePBX 的新手,我在这里关注了信息:https ://github.com/asterisk-java/asterisk-java/wiki/Getting-Started
我的设置类如下所示:
package org.asteriskjava.examples.activities;
import org.asteriskjava.pbx.DefaultAsteriskSettings;
public class MyAsteriskSettings extends DefaultAsteriskSettings
{
@Override
public String getManagerPassword()
{
return [ my password ]; // this password MUST match the password (secret=) in manager.conf
}
@Override
public String getManagerUsername()
{
return "admin"; // this MUST match the section header '[myconnection]' in manager.conf
}
@Override
public String getAsteriskIP()
{
return "10.2.3.158"; // The IP address or FQDN of your Asterisk server.
}
@Override
public String getAgiHost()
{
return "127.0.0.1/255.255.255.0"; // The IP Address of FQDN of you asterisk-java application.
}
}
我的“PBXFactory 的一次性初始化”课程如下所示:
package org.asteriskjava.examples.activities;
import org.asteriskjava.pbx.PBXFactory;
import org.asteriskjava.pbx.internal.core.AsteriskPBX;
import org.asteriskjava.util.Log;
import org.asteriskjava.util.LogFactory;
public class Init_PBX_Factory
{
static private Log logger=LogFactory.getLog(Init_PBX_Factory.class);
static public void main(String[] args)
{
try
{
PBXFactory.init(new MyAsteriskSettings()); // Initialise the PBX Factory. You need to implement your own AsteriskSettings class.
AsteriskPBX asteriskPbx=(AsteriskPBX)PBXFactory.getActivePBX(); // Activities utilise an agi entry point in your dial plan. You can create your own
asteriskPbx.createAgiEntryPoint(); // entry point in dialplan or have asterisk-java add it automatically as we do here.
}
catch (Exception e)
{
e.printStackTrace();
logger.error("Failed to Init_PBX_Factory : ",e);
}
}
}
但是在我运行“Init_PBX_Factory”之后,我得到了以下错误:
Oct 09, 2019 2:32:04 PM org.asteriskjava.pbx.internal.core.AsteriskPBX <init>
SEVERE: java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.asteriskjava.pbx.internal.managerAPI.Connector.checkIfAsteriskRunning(Connector.java:64)
at org.asteriskjava.pbx.internal.managerAPI.Connector.connect(Connector.java:38)
at org.asteriskjava.pbx.internal.core.CoherentManagerConnection.configureConnection(CoherentManagerConnection.java:390)
at org.asteriskjava.pbx.internal.core.CoherentManagerConnection.<init>(CoherentManagerConnection.java:172)
at org.asteriskjava.pbx.internal.core.CoherentManagerConnection.init(CoherentManagerConnection.java:123)
at org.asteriskjava.pbx.internal.core.AsteriskPBX.<init>(AsteriskPBX.java:92)
at org.asteriskjava.pbx.internal.core.AsteriskPBX.<clinit>(AsteriskPBX.java:77)
at org.asteriskjava.pbx.PBXFactory.getActivePBX(PBXFactory.java:12)
at org.asteriskjava.pbx.PBXFactory.init(PBXFactory.java:21)
at org.asteriskjava.examples.activities.Init_PBX_Factory.main(Init_PBX_Factory.java:17)
java.lang.NullPointerException
at org.asteriskjava.pbx.internal.core.AsteriskPBX.performPostCreationTasks(AsteriskPBX.java:118)
at org.asteriskjava.pbx.PBXFactory.init(PBXFactory.java:21)
at org.asteriskjava.examples.activities.Init_PBX_Factory.main(Init_PBX_Factory.java:17)
Oct 09, 2019 2:32:04 PM org.asteriskjava.examples.activities.Init_PBX_Factory main
SEVERE: Failed to Init_PBX_Factory :
java.lang.NullPointerException
at org.asteriskjava.pbx.internal.core.AsteriskPBX.performPostCreationTasks(AsteriskPBX.java:118)
at org.asteriskjava.pbx.PBXFactory.init(PBXFactory.java:21)
at org.asteriskjava.examples.activities.Init_PBX_Factory.main(Init_PBX_Factory.java:17)
我做错了什么,如何解决?