aspose file tools*
The moose likes Other Java Products and Servers and the fly likes java asterisk Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "java asterisk" Watch "java asterisk" New topic
Author

java asterisk

Omar I Mohaidat
Greenhorn

Joined: May 23, 2010
Posts: 6
Hello everybody,

i am new in asterisk and IVR system, there is authentication problem when run this code,

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

this.managerConnection = factory.createManagerConnection();
}

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

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

i can't connect to asterisk server but the strange when i use SIP phone i can connct to server using same ip, username, password, and extention.

any help please
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Omar, could you please use http://faq.javaranch.com/java/UseCodeTags while posting code? What does "i can't connect to asterisk server" means? Any error messages?
Omar I Mohaidat
Greenhorn

Joined: May 23, 2010
Posts: 6
Misha Ver wrote:Omar, could you please use http://faq.javaranch.com/java/UseCodeTags while posting code? What does "i can't connect to asterisk server" means? Any error messages?


i tried to connect to asterisk server, using this code :

public HelloManager() throws IOException
{
ManagerConnectionFactory factory = new ManagerConnectionFactory(
"localhost", "manager", "pa55w0rd");

this.managerConnection = factory.createManagerConnection();
}

i got authentication fialed error message.

i tried to connect to asterisk server using SIP phone using same IP, username, and password on the same machine, it connected without problems.

i want to know why i can't connect using my java code (and got authentication failed error) and i can connect using SIP phone.


thank you in advance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java asterisk