Outbound calls using AMI with java

General discussions about AsteriskNOW.

Moderators: Moderator, Support

Outbound calls using AMI with java

Postby sulfikarnasar » Thu Feb 06, 2014 7:27 am

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;

Code: Select all
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(
"", "admin", "admin");

this.managerConnection = factory.createManagerConnection();

public void run() throws IOException, AuthenticationFailedException,
OriginateAction originateAction;
ManagerResponse originateResponse;

originateAction = new OriginateAction();
originateAction.setPriority(new Integer(1));
originateAction.setTimeout(new Integer(30000));
// connect to Asterisk and log in


// 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

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

helloManager = new HelloManager();

Feb 06, 2014 4:04:16 PM org.asteriskjava.manager.internal.ManagerConnectionImpl connect
INFO: Connecting to
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(ManagerConnectionImpl.java:578)
at org.asteriskjava.manager.internal.ManagerConnectionImpl.login(ManagerConnectionImpl.java:438)
at org.asteriskjava.manager.internal.ManagerConnectionImpl.login(ManagerConnectionImpl.java:423)
at org.asteriskjava.manager.DefaultManagerConnection.login(DefaultManagerConnection.java:294)
at asteriskjtapi.HelloManager.run(HelloManager.java:49)
at asteriskjtapi.HelloManager.main(HelloManager.java:67)
pls help me to complete this task
Here I am using the credentials in FreePBX. Is this right one to access ConnectionManager?
Please help me to complete this task
Posts: 7
Joined: Tue Dec 17, 2013 11:35 pm

Re: Outbound calls using AMI with java

Postby navaismo » Thu Feb 06, 2014 8:55 am

Please dont triplicate threads.
Salt of the Asterisk
Posts: 1610
Joined: Mon Dec 07, 2009 1:30 pm
Location: Mexico City, Mexico

Return to AsteriskNOW General

Who is online

Users browsing this forum: No registered users and 1 guest