Hi all,
I am a newbie to Asterisk. I am using the Asterisk-JAVA API to call Asterisk server using an extension and a setup account. Using the code and the configuration i am able to call the desired extension successfully from a softphone.But when i try to do the same using the JAVA code then the call gets processed by the “from-external-sip” extension and not by the extension i have setup in the code.Below is the code :
import java.io.IOException;
import org.asteriskjava.*;
import org.asteriskjava.manager.*;
import org.asteriskjava.manager.action.OriginateAction;
import org.asteriskjava.manager.response.ManagerResponse;
import org.asteriskjava.manager.AuthenticationFailedException;
import org.asteriskjava.manager.ManagerConnection;
import org.asteriskjava.manager.ManagerConnectionFactory;
import org.asteriskjava.manager.TimeoutException;
public class TryConnect {
private ManagerConnection managerConnection;
public TryConnect() throws IOException
{
ManagerConnectionFactory factory = new ManagerConnectionFactory("xxx.xxx.xxx.xxx", "xxx", "xxxx");
this.managerConnection = factory.createManagerConnection();
}
public void run() throws IOException, AuthenticationFailedException,TimeoutException
{
OriginateAction originateAction;
ManagerResponse originateResponse;
originateAction = new OriginateAction();
originateAction.setChannel("SIP/10001@xxx.xxx.xxx.xxx");
originateAction.setContext("from-internal");
originateAction.setExten("1000");
originateAction.setCallerId("1000");
originateAction.setPriority(new Integer(1));
originateAction.setTimeout(new Integer(5000));
// 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, 5000);
// 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
{
TryConnect helloManager;
helloManager = new TryConnect();
helloManager.run();
}
}
Below is the output in the CLI on making the call from the JAVA code :-
-- Executing [10001@from-sip-external:1] NoOp("SIP/192.168.220.10-00000007", "Received incoming SIP connection from unknown peer to 10001") in new stack
-- Executing [10001@from-sip-external:2] Set("SIP/192.168.220.10-00000007", "DID=10001") in new stack
-- Executing [10001@from-sip-external:3] Goto("SIP/192.168.220.10-00000007", "s,1") in new stack
-- Goto (from-sip-external,s,1)
-- Executing [s@from-sip-external:1] GotoIf("SIP/192.168.220.10-00000007", "0?checklang:noanonymous") in new stack
-- Goto (from-sip-external,s,5)
-- Executing [s@from-sip-external:5] Set("SIP/192.168.220.10-00000007", "TIMEOUT(absolute)=15") in new stack
-- Channel will hangup at 2015-07-17 00:04:16.259 CEST.
-- Executing [s@from-sip-external:6] Log("SIP/192.168.220.10-00000007", "WARNING,"Rejecting unknown SIP connection from 192.168.220.10"") in new stack
-- Executing [s@from-sip-external:7] Answer("SIP/192.168.220.10-00000007", "") in new stack
-- Executing [1000@from-internal:1] Dial("SIP/192.168.220.10-00000006", "SIP/1000") in new stack
== Everyone is busy/congested at this time (1:0/0/1)
-- Executing [1000@from-internal:2] Answer("SIP/192.168.220.10-00000006", "") in new stack
-- Executing [1000@from-internal:3] Playback("SIP/192.168.220.10-00000006", "pls-try-call-later") in new stack
-- Executing [s@from-sip-external:8] Wait("SIP/192.168.220.10-00000007", "2") in new stack
-- <SIP/192.168.220.10-00000006> Playing 'pls-try-call-later.ulaw' (language 'en')
== Manager 'admin' logged off from 192.168.220.20
-- Executing [s@from-sip-external:9] Playback("SIP/192.168.220.10-00000007", "ss-noservice") in new stack
-- <SIP/192.168.220.10-00000007> Playing 'ss-noservice.ulaw' (language 'en')
-- Executing [1000@from-internal:4] Hangup("SIP/192.168.220.10-00000006", "") in new stack
== Spawn extension (from-internal, 1000, 4) exited non-zero on 'SIP/192.168.220.10-00000006'
-- Executing [h@from-internal:1] Hangup("SIP/192.168.220.10-00000006", "") in new stack
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/192.168.220.10-00000006'
== Spawn extension (from-sip-external, s, 9) exited non-zero on 'SIP/192.168.220.10-00000007'
-- Executing [h@from-sip-external:1] NoOp("SIP/192.168.220.10-00000007", "Received incoming SIP connection from unknown peer to h") in new stack
-- Executing [h@from-sip-external:2] Set("SIP/192.168.220.10-00000007", "DID=s") in new stack
-- Executing [h@from-sip-external:3] Goto("SIP/192.168.220.10-00000007", "s,1") in new stack
-- Goto (from-sip-external,s,1)
-- Executing [s@from-sip-external:1] GotoIf("SIP/192.168.220.10-00000007", "0?checklang:noanonymous") in new stack
-- Goto (from-sip-external,s,5)
-- Executing [s@from-sip-external:5] Set("SIP/192.168.220.10-00000007", "TIMEOUT(absolute)=15") in new stack
-- Channel will hangup at 2015-07-17 00:04:18.584 CEST.
-- Executing [s@from-sip-external:6] Log("SIP/192.168.220.10-00000007", "WARNING,"Rejecting unknown SIP connection from 192.168.220.10"") in new stack
-- Executing [s@from-sip-external:7] Answer("SIP/192.168.220.10-00000007", "") in new stack
== Spawn extension (from-sip-external, s, 7) exited non-zero on 'SIP/192.168.220.10-00000007'
Please help me out why the call is getting directed to the “from-external-sip” extension and not the “from-internal” extension as i have set up in the code.
Thanks.