Asterisk outgoing call using java is not working

A forum for Skype For Asterisk users to ask questions and get advice from other users

Moderators: twilson, pete engler

Asterisk outgoing call using java is not working

Postby dharmendrasahu » Sat Mar 19, 2011 12:09 am

we are trying to make a outgoing call with java Asterisk but we are unable to make a call.plz provide help.
here i attached my all code.

HelloManager.java

package outgongcalls;

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("Connection Created");
}

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

originateAction = new OriginateAction();
originateAction.setChannel("SIP/102");
originateAction.setExten("102");
originateAction.setPriority(new Integer(1));
originateAction.setVariable("dharmendra", "9543229226");
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();
}
}
extension.conf

general
static=yes
writeprotect=yes
autofallthrough=yes
clearglobalvars=no
priorityjumping=no

globals

OUTBOUNDTRUNK=SIP/192.168.1.161
INTERCOM=SIP ; protocol for the intercom
IVR-OPERATOR=0 ; IVR key for the operator
OPERATOR=501 ; actual extension of the operator

incoming

include => internal

exten => 100,n,Answer()
exten => 100,n,Background(enter-ext-of-person)
exten => 100,n,WaitExten()

exten => 100,1,Dial(SIP/102)

exten => 100,n,Playback(vm-nobodyavail)
exten => 100,n,Hangup()

exten => t,1,Playback(vm-goodbye)
exten => t,n,Hangup()

internal

include => outbound-local
include => outbound-long-distance

outbound-local

exten => _9XXXXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN}) ; Mobile
exten => _9XXXXXXXXX,n,Congestion()
exten => _9XXXXXXXXX,n,Hangup()

exten => _8XXXXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN}) ; Mobile
exten => _8XXXXXXXXX,n,Congestion()
exten => _8XXXXXXXXX,n,Hangup()


exten => _2XXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN}) ; MTNL
exten => _2XXXXXXX,n,Congestion()
exten => _2XXXXXXX,n,Hangup()

exten => _3XXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN}) ; Reliance
exten => _3XXXXXXX,n,Congestion()
exten => _3XXXXXXX,n,Hangup()


exten => _5XXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN}) ; Tata
exten => _5XXXXXXX,n,Congestion()
exten => _5XXXXXXX,n,Hangup()

exten => _4XXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN}) ; Airtel
exten => _4XXXXXXX,n,Congestion()
exten => _4XXXXXXX,n,Hangup()

for other state mobile calls
exten => _0XXXXXXXXXX,1,Dial(${OUTBOUNDTRUNK},${EXTEN}); outstation mobile calls
exten => _0XXXXXXXXXX,n,Congestion()
exten => _0XXXXXXXXXX,n,Hangup()


exten => 996,1,Dial(${OUTBOUNDTRUNK}/996)
exten => 9962,1,Dial(${OUTBOUNDTRUNK}/996)

outbound-long-distance
exten => _91XXXXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN:1})
exten => _91XXXXXXXXX,n,Playtones(congestion)
exten => _91XXXXXXXXX,n,Hangup()

sip.conf
general
;port=5060 ; Port to bind to (SIP is 5060)
;bindaddr=0.0.0.0 ; Address to bind to (all addresses on machine)
videosupport=yes
srvlookup=yes
disallow=all ; First, disallow all codecs, then allow codecs one by one
allow=ulaw
allow=alaw
allow=g729
allow=g723.1
allow=g726
allow=gsm
allow=h261
context = internal ; Send unknown SIP callers to this context
callerid = home
;nat=yes ; Important if your Asterisk server and extensions are behind NAT
qualify=yes
canreinvite=no
dtmfmode=RFC2833
callevents = yes

100
user=100
type=friend
secret=100
host=192.168.1.161
;host=dynamic
callerid = User-100
context=incoming

d26e8f09b6f22113bd57db9ffc089d96
user=d26e8f09b6f22113bd57db9ffc089d96
type=friend
secret=d26e8f09b6f22113bd57db9ffc089d96
host=192.168.1.161
;host=dynamic
callerid = User-1
context=from-pstn

102
user=102
type=friend
secret=102
host=192.168.1.161
;host=dynamic
callerid = User-2
context=internal
mailbox=102

b633708bf3ec4c61144cd3c6c3b43d61
user=b633708bf3ec4c61144cd3c6c3b43d61
allow=all
type=friend
secret=b633708bf3ec4c61144cd3c6c3b43d61
;host=192.168.1.161
host=dynamic
callerid = User-3
context=internal
mailbox=b633708bf3ec4c61144cd3c6c3b43d61
canreinvite=no
qualify=yes
allow=ulaw
allow=alaw


;104
;user=104
;type=friend
;secret=104
;host=dynamic
;callerid = User-4
;context=internal
;mailbox=104

111
user=111
type=friend
secret=111
host=dynamic
callerid = User-111
context=internal
sendrpid=yes
;trustrpid=no

112
user=112
type=friend
secret=112
host=dynamic
callerid = User-112
context=internal

113
user=113
type=friend
secret=113
host=dynamic
callerid = User-113
context=internal

114
user=114
type=friend
secret=114
host=dynamic
callerid = User-114
context=internal


manager.conf
;
; AMI - The Asterisk Manager Interface
;
; Third party application call management support and PBX event supervision
;
; This configuration file is read every time someone logs in
;
; Use the "show manager commands" at the CLI to list available manager commands
; and their authorization levels.
;
; "show manager command <command>" will show a help text.
;
; ---------------------------- SECURITY NOTE -------------------------------
; Note that you should not enable the AMI on a public IP address. If needed,
; block this TCP port with iptables (or another FW software) and reach it
; with IPsec, SSH, or SSL vpn tunnel
;
general
enabled = yes
port = 5038
bindaddr = 0.0.0.0
;displayconnects = yes


manager
secret=pa55w0rd
;permit=192.168.1.125/255.255.255.0
read=system,call,log,verbose,agent,command,user
write=system,call,log,verbose,agent,command,user

;mark
;secret = mysecret
;deny=0.0.0.0/0.0.0.0
;permit=209.16.236.73/255.255.255.0
;read=system,call,log,verbose,agent,command,user
;write=system,call,log,verbose,agent,command,user

;
; If the device connected via this user accepts input slowly,
; the timeout for writes to it can be increased to keep it
; from being disconnected (value is in milliseconds)
;
; writetimeout = 100
;
; Authorization for various classes
;read = system,call,log,verbose,command,agent,user
;write = system,call,log,verbose,command,agent,user
dharmendrasahu
Newsterisk
 
Posts: 1
Joined: Fri Mar 18, 2011 11:59 pm

Return to Skype For Asterisk

Who is online

Users browsing this forum: No registered users and 2 guests