Call is not initiating between two extensions through Progra

Hi,

I am completely new to Asterisk-Java and following
http://www.asterisk-java.org/development/tutorial.html link. I am able to execute basic “Hello AGI” example. Now, I am trying to execute “Hello Manager” example. But, nothing is happening.

I have two extensions (121, 115) and connected to my Asterisk server through two soft phones (Xlite). I am able to make call between two extensions directly. Now, I want to initiate a call from 121 to extension 115 using Asterisk-Java program.

Please find my below configuration step by step:

  1. /etc/asterisk/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=all
write=all

  1. /etc/asterisk/sip.conf

[121]
type=friend
username=121
secret=cmp1
callerid="cmp121"
host=dynamic
context=abcd

[115]
type=friend
username=115
secret=cmp2
callerid="cmp115"
host=dynamic
context=abcd

  1. /etc/asterisk/extensions.conf

[abcd]
exten => 121,1,Dial(SIP/121,15)
exten => 121,2,Hangup

[abcd]
exten => 115,1,Dial(SIP/115,15)
exten => 115,2,Hangup

  1. HelloManager.java

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(
             "localhost", "manager", "password");
     this.managerConnection = factory.createManagerConnection();
 }

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

     originateAction = new OriginateAction();
     originateAction.setChannel("SIP/121");
     originateAction.setContext("abcd");
     originateAction.setExten("115");
     originateAction.setPriority(new Integer(1));
     //originateAction.setTimeout(new Integer(30000));

     managerConnection.login();
     originateResponse = 

managerConnection.sendAction(originateAction, 30000);

     // print out whether the originate succeeded or not
     System.out.println(originateResponse.getResponse());

     managerConnection.logoff();
 }

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

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

}

  1. Connected to Asterisk server (asterisk -rvvvvv)
  2. Start Asterisk-Java ( java -jar asterisk-java.jar)
  3. Compiled the program (javac -cp asterisk-java.jar HelloManager.java)
  4. HelloManager.class file is created.

I executed the above 8 steps and not seeing any messages on Asterisk-Java server console (on *:4573) and also not seeing any messages on Asterisk server console. Call is also not forming between the extensions.

What I need to do in addition? Any help would be appreciated.

Thanks in advance.

Regards,
CMP

You actually have two devices, not two extensions.

Your dialplan is invalid as you have two instances of the same context without a (+) on the second one.

I’m not familiar with your AMI library, so I don’t know what debugging features it provides.

Hello David,

Thanks for your reply. Please note that I am able to call between the extensions with the above dial plan from soft phones. Anyway, I tried as you suggested. But, I am not getting anything. Please find the below modified extensions.conf file:

Scenario 1:
[abcd]
exten => 121,1,Dial(SIP/121,15)
exten => 121,2,Hangup

[abcd] (+)
exten => 115,1,Dial(SIP/115,15)
exten => 115,2,Hangup

Scenario 2:
[abcd]
exten => 121,1,Dial(SIP/121,15)
exten => 121,2,Hangup

exten => 115,1,Dial(SIP/115,15)
exten => 115,2,Hangup

Any update would be appreciated. Thanks in advance.

Regards,
CMP

Scenario 2 is the normal way. For scenario 1, there should not be a space between the ] and the (.

You will need to enable debugging in you AMI library. You may need to contact the developers of the library for further support on doing that.