0

我在 manager.conf 中创建了一个名为:mark 的用户管理器,在名为“utilisateur”的“sip.conf”中,我想通过 Asterisk-java 调用用户:“utilisateur”,我尝试了以下代码:

  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",  "mark", "1234");

    this.managerConnection = factory.createManagerConnection();
   }

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

      originateAction = new OriginateAction();
      originateAction.setChannel("SIP/utilisateur");
     originateAction.setContext("default");
     originateAction.setExten("2222");
     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(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();
  }
  }

 And in extension.conf i added this extension :

[default]
 exten => 2222,1,Dial(SIP/utilisateur)
 exten => 2222,2,Answer

我从星号服务器收到此错误,所以有人可以帮助我:

 Exception in thread "main" org.asteriskjava.manager.TimeoutException: Timeout waiting for response to Originate
at org.asteriskjava.manager.internal.ManagerConnectionImpl.sendAction(ManagerConnectionImpl.java:809)
at org.asteriskjava.manager.DefaultManagerConnection.sendAction(DefaultManagerConnection.java:289)
at HelloManager.run(HelloManager.java:40)
at HelloManager.main(HelloManager.java:54)
4

1 回答 1

2

您没有设置在出站呼叫者中呼叫的号码。

originateAction.setCallerId(<phonenumber>);
于 2014-06-18T10:13:45.373 回答