Hi ,
I would like to initiate a call from extension number to another in LAN network. I have done this task through FreePBX GUI. Now I am trying to execute this task by using Asterisk AMI with java code. Below java code shows some exception while in debugging.
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.68.173”, “admin”, “admin”);
this.managerConnection = factory.createManagerConnection();
}
public void run() throws IOException, AuthenticationFailedException,
TimeoutException
{
OriginateAction originateAction;
ManagerResponse originateResponse;
originateAction = new OriginateAction();
originateAction.setChannel(“SIP/1010”);
originateAction.setContext(“default”);
originateAction.setExten(“2020”);
originateAction.setPriority(new Integer(1));
originateAction.setTimeout(new Integer(30000));
// 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(“Enter Response=”+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();
}
}
exception****
run:
Feb 06, 2014 4:04:16 PM org.asteriskjava.manager.internal.ManagerConnectionImpl connect
INFO: Connecting to 192.168.68.173:5038
Feb 06, 2014 4:04:17 PM org.asteriskjava.manager.internal.ManagerConnectionImpl setProtocolIdentifier
INFO: Connected via Asterisk Call Manager/1.3
Feb 06, 2014 4:04:17 PM org.asteriskjava.manager.internal.ManagerConnectionImpl setProtocolIdentifier
WARNING: Unsupported protocol version ‘Asterisk Call Manager/1.3’. Use at your own risk.
Feb 06, 2014 4:04:18 PM org.asteriskjava.manager.internal.ManagerConnectionImpl disconnect
INFO: Closing socket.
Feb 06, 2014 4:04:18 PM org.asteriskjava.manager.internal.ManagerReaderImpl run
INFO: Terminating reader thread: No more lines available: null
Exception in thread “main” org.asteriskjava.manager.AuthenticationFailedException: Authentication failed
at org.asteriskjava.manager.internal.ManagerConnectionImpl.doLogin(ManagerConnecti onImpl.java:578)
at org.asteriskjava.manager.internal.ManagerConnectionImpl.login(ManagerConnection Impl.java:438)
at org.asteriskjava.manager.internal.ManagerConnectionImpl.login(ManagerConnection Impl.java:423)
at org.asteriskjava.manager.DefaultManagerConnection.login(DefaultManagerConnectio n.java:294)
at asteriskjtapi.HelloManager.run(HelloManager.java:49)
at asteriskjtapi.HelloManager.main(HelloManager.java:67)
pls help me to complete this task