cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
478
Views
0
Helpful
2
Replies

getCallingAddress / getCalledAddress return null

rene.herbrich
Level 1
Level 1

Hi,

I'm currently developing a Java application, which observes serveral lines. My goal is to inform people, if a destination is reachable again, after they tried to call this destination prior to that.

So far so good, everything is working fine, except for one situation: if I'm calling a destination which is busy, I'm not able to get the CallingAddress / the CalledAddress, as both are null. Here's my code (I'm using a CallObserver to observe my own line and I'm evaluating the CallEvents. In this case it's the ConnCreated Event):

if (eventList[i] instanceof ConnCreatedEv) {     
ConnCreatedEv ev = (ConnCreatedEv)eventList[i];           
CiscoCall call = (CiscoCall)ev.getCall();
             
Address srcAddress = call.getCallingAddress();
Address destAddress = call.getCalledAddress();            
             
if(srcAddress != null && destAddress != null) {
  // Do something
}
}

After some debugging I found out that it's some kind of timing issue, as in debug mode and breakpoint set to the code block above the objects were never null. Currently my work around is surrounding srcAddress = call.getCallingAddress() and destAddress = call.getCalledAddress() with a while loop:

long startTime = System.currentTimeMillis();
long currentTime = System.currentTimeMillis();

Address srcAddress = call.getCallingAddress();
Address destAddress = call.getCalledAddress();

while(srcAddress == null || destAddress == null) {
currentTime = System.currentTimeMillis();
long difTime = currentTime - startTime;
              
try {
  Thread.sleep(250);
} catch (Exception ex) {}
              
srcAddress = call.getCallingAddress();
destAddress = call.getCalledAddress();
              
if(difTime > 500) break;             
}

if(srcAddress != null && destAddress != null) {
// Do something
}

It takes about 200-300ms to get the Address objects and my code is working fine again. But in my eyes it's pretty ugly and I'm not sure, if it can cause other issues with CUCM? Is there anything I can do, to prevent that issue? For the records: we're using CUCM 9.1.2.12900-11 and the JTAPI Specification-Version: 1.2 / CiscoJtapiClient Implementation-Version: 9.1(2.11017)-1

Thank you in advance!

1 Accepted Solution

Accepted Solutions

mpotluri
Level 5
Level 5

Hi Rene,

    By the time application receives the ConnCreatedEv calling address is set for the call. Called Address will be null at this time and will stay null till application receives ConnFailedEv.

I am not sure why application is seeing null for calling address. Are you using synchronous or Asynchronous observer? Are you seeing same behavior with JTRace sample app? Readme file in the JTAPI install location should have steps to run JTrace.

View solution in original post

2 Replies 2

mpotluri
Level 5
Level 5

Hi Rene,

    By the time application receives the ConnCreatedEv calling address is set for the call. Called Address will be null at this time and will stay null till application receives ConnFailedEv.

I am not sure why application is seeing null for calling address. Are you using synchronous or Asynchronous observer? Are you seeing same behavior with JTRace sample app? Readme file in the JTAPI install location should have steps to run JTrace.

Oh, sorry. You were right, only getCalledAddress returned null. Evaluating ConnFailedEV was the missing bit, thank you. My application is working fine now.

Just one question: are there any schematics, which describe the call flow regarding the Events? For example, if I call someone and he's busy, which Events occur etc.?