Asterisk outgoing call using java is not work

gcr
Joined: Wed 16 of Mar, 2011

Re: Asterisk outgoing call using java is not work

Posted:Thu 24 of Mar, 2011 (00:10 UTC)
I noticed no one has answered you so I'll try. I am admittedly new to Asterisk and asterisk-java, but since we are both attempting to do similar things perhaps we can help each other.

I was able to place a SIP call--in other words get the phone to ring--by adding the IP address of the SIP server thus:

My code:
originateAction.setChannel("SIP/17023667879@216.86.150.76");

Your code:
originateAction.setChannel("SIP/102"<try ip here>);

Including the IP address as shown above, makes no sense to me in light of the fact that the sip.conf file carries the same IP address. Why isn't it used?

My sip.conf

[general]
context=dialer
bindaddr=192.168.1.102 ; This is my asterisk server.
bindport=5060                ; This is where asterisk listens (I hope)
disallow=all
allow=g723.1
allow=g729a
allow=ulaw
allow=gsm
language=en
srvlookup=yes
transport=udp

register => Iam@216.86.150.76:5060 ; If all I'm doing is outbound   
                                                       ; calls, do I even need this?

[dialer]
type=peer
host=216.86.150.76 ; This is the SIP server I'm trying to use.
dtmfmode=rfc2833
insecure=invite

dharmendrasahu
Joined: Fri 18 of Mar, 2011

Asterisk outgoing call using java is not work

Posted:Fri 18 of Mar, 2011 (08:46 UTC)
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

[101]
user=101
type=friend
secret=101
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

[103]
user=103
allow=all
type=friend
secret=103
;host=192.168.1.161
host=dynamic
callerid = User-3
context=internal
mailbox=103
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