jtapi Address is out of service error

753 Views Asked by At

I am new to JTAPI I Install Cisco Client And Test It. and every things was alright.Then I decide to Write Code to call a Phone via JTAPI and I got the following Exception :

"Address is out of service"

I cant understand where The problem Is

Here's the code :

public static final void main(String args[]) {
     String providerName = "192.168.10.60";

           String login = "sajjad";

           String passwd = "sajjad";

                String providerString = providerName + ";login=" + login + ";passwd=" + passwd;

/*
 * Create a provider by first obtaining the default implementation of
 * JTAPI and then the default provider of that implementation.
 */
Provider myprovider = null;
try {
  JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);
  myprovider = peer.getProvider(providerString);
} catch (Exception excp) {
  System.out.println("Can't get Provider: " + excp.toString());
  System.exit(0);
}
System.out.println("Provider: " + myprovider.toString());

Address origaddr = null;
Terminal origterm = null;
try {
  origaddr = myprovider.getAddress("101");
  System.out.println(origaddr.getName());

  /* Just get some Terminal on this Address */
  Terminal[] terminals = origaddr.getTerminals();
  if (terminals == null) {
    System.out.println("No Terminals on Address.");
    System.exit(0);
  }  
  origterm = terminals[0];
  System.out.println("terminal " + java.util.Arrays.toString(terminals));
} catch (Exception excp) {
   System.out.println("No Terminals " + excp.toString());
}


  /*
 * Create the telephone call object and add an observer.
 */
Call mycall = null;
try {
  mycall = myprovider.createCall();
  System.out.println("my call " + mycall);
  mycall.addObserver(new MyOutCallObserver());

} catch (Exception excp) {
  System.out.println("No call " + excp.toString());
}

try {
    //here is the exception
   Connection c[] = mycall.connect(origterm, origaddr, "105");


} catch (Exception excp) {

    System.out.println("No calling " + excp.toString());
} 

And The output:

Provider: (P1-sajjad)
101
terminal [SEP001A2F49026D]
my call (P1-sajjad) GCID=(1,2106)->IDLE
No calling com.cisco.jtapi.InvalidStateExceptionImpl: Address is out of service

Any Help Will be Appreciated

2

There are 2 best solutions below

0
On

To follow on from the previous answer, I was recently working on a JTAPI app and ran into this exact issue.

Turns out, you also need to register a call observer before you can create a call.

Example:

origterm.addCallObserver(this)

This will also require an overriding callChangedEvent to be added to the class:

@Override
public void callChangedEvent(CallEv[] callEvents) {
    for (CallEv callev : callEvents) {
        switch(callev.getID()) {
            case ConnConnectedEv.ID:
                System.out.println("Call Connected");
        }
    }
};
0
On

If you haven't figured it out already, make sure the phone with 101 as address is online and connected to the Cisco call manager correctly. Also make sure your Application User has access to the phone (put it in controlled devices in the config of the user)