Hi All,
I am newbie , I just want to create java application to make a call to asterisk (1.8)
by referring the asterisk java site (asterisk-java.org/0.2/tutorial.html)
the following is my code :
manager.conf
[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0
[manager]
secret=pa55w0rd
permit=0.0.0.0/0.0.0.0
read=all
write=all
sip.conf
[ivan]
type=friend
defaultuser=ivan
context=test
secret=ivan
host=dynamic
allow=all
extensions.conf
[test]
exten => 567,1,Answer()
exten => 567,2,Playback(welcome)
exten => 567,3,SayUnixTime(-1,UTC)
exten => 567,4,SayUnixTime(,CET,kMbdY)
exten => 567,5,Playback(vm-goodbye)
exten => 567,6,Hangup()
HelloManager.java
package com.asterisk.example;
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();
System.out.println("Inside the constructor");
}
public void run() throws IOException, AuthenticationFailedException,
TimeoutException
{
OriginateAction originateAction;
ManagerResponse originateResponse;
originateAction = new OriginateAction();
originateAction.setChannel("SIP/ivan");
originateAction.setAccount("ivan");
originateAction.setContext("test");
originateAction.setExten("567");
originateAction.setPriority(new Integer(1));
originateAction.setTimeout(new Integer(300000));
// connect to Asterisk and log in
managerConnection.login();
System.out.println("successfully connectiong to asterisk");
// send the originate action and wait for a maximum of 30 seconds for Asterisk
// to send a reply
originateResponse = managerConnection.sendAction(originateAction, 300000);
// 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();
}
}
logs of java application
Inside the constructor
Jul 20, 2011 10:49:15 AM org.asteriskjava.manager.internal.ManagerConnectionImpl connect
INFO: Connecting to localhost:5038
Jul 20, 2011 10:49:15 AM org.asteriskjava.manager.internal.ManagerConnectionImpl setProtocolIdentifier
INFO: Connected via Asterisk Call Manager/1.1
Jul 20, 2011 10:49:15 AM org.asteriskjava.manager.internal.EventBuilderImpl buildEvent
INFO: No event class registered for event type 'fullybooted', attributes: {privilege=system,all, event=FullyBooted, status=Fully Booted}. Please report at http://jira.reucon.org/browse/AJ
Jul 20, 2011 10:49:15 AM org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin
INFO: Successfully logged in
Jul 20, 2011 10:49:15 AM org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin
INFO: Determined Asterisk version: Asterisk 1.6
successfully connectiong to asterisk
Error
Jul 20, 2011 10:49:15 AM org.asteriskjava.manager.internal.ManagerReaderImpl run
INFO: Terminating reader thread: No more lines available: null
Jul 20, 2011 10:49:15 AM org.asteriskjava.manager.internal.ManagerConnectionImpl disconnect
INFO: Closing socket.
logs of asterisk console
== Manager 'manager' logged on from 127.0.0.1
[Jul 20 11:01:06] NOTICE[3716]: channel.c:5167 __ast_request_and_dial: Unable to request channel SIP/ivan
== Manager 'manager' logged off from 127.0.0.1
logs /var/log/asterisk/messages
[Jul 20 09:26:19] NOTICE[2292] channel.c: Unable to request channel SIP/ivan
any one can help to fix the above error and show me how to run the above program to make call to asterisk from java application