Alexey Vinogradov
Alexey Vinogradov

Reputation: 97

How to fix PlatformExceptionImpl with code of 100 when excecuting `javax.telephony.Call#connect`?

When I calling:

final JtapiPeer jtapiPeer = JtapiPeerFactory.getJtapiPeer(null);
final CiscoProvider ciscoProvider = jtapiPeer.getProvider(String.format(CUCM_LOGIN_STRING,
                        telephonyPropertyCucm.getHost(),
                        telephonyPropertyCucm.getLogin(),
                        telephonyPropertyCucm.getPassword()));
final Call call = ciscoProvider.createCall();
final Address addressFrom = ciscoProvider.getAddress(from);
addressFrom.addCallObserver((callEvs) -> {});
call.connect(addressFrom.getTerminals()[0], addressFrom, to);

Then I've got sometimes a PlatformExceptionImpl:

...
Caused by: com.cisco.jtapi.PlatformExceptionImpl: Could not meet post conditions of connect()
    at com.cisco.jtapi.CallImpl.connect(CTQF) ~[cisco-jtapi-0.0.1-SNAPSHOT.jar!/:11.5(1.13045)-1 Release]
    at com.cisco.jtapi.CallImpl.connect(CTQF) ~[cisco-jtapi-0.0.1-SNAPSHOT.jar!/:11.5(1.13045)-1 Release]
    at ru.bcs.telephony.jtapi.starter.helper.call.CallingExecutable.execute(CallingExecutable.java:33) ~[telephony-jtapi-spring-boot-starter-1.1-RELEASE.jar!/:na]
    ... 124 common frames omitted

I've already tried to increase JtapiPostConditionTimeout in jtapi.ini to 20 seconds (as I can see in the documentation it is the max value).

I expect that this exception doesn't appear.

But only sometimes this exception appears.

P.S. Fields of the exception are follows:

PLATFORM EXCEPTION. It's a message: Could not meet post conditions of connect(). It's error code: 100. It's error name: . It's error description: 

Upvotes: 0

Views: 584

Answers (1)

David Staudt
David Staudt

Reputation: 386

Objects like Provider, Address, Terminal have an in-service/out-of-service state - opening one (e.g. by adding an observer) kicks off the process of connecting to CUCM CTI Manager and establishing observation/control of the object, but that takes some time.

In general, you will want to wait for in-service events for those objects to arrive before attempting any operations on them:

    Handler handler = new Handler();

    // Create the JtapiPeer object, representing the JTAPI library
    System.out.println("Initializing Jtapi");
    JtapiPeer peer = JtapiPeerFactory.getJtapiPeer( null );

    // Create and open the Provider, representing a JTAPI connection to CUCM CTI Manager
    String providerString = String.format( "%s;login=%s;passwd=%s", 
        System.getenv( "CUCM" ), System.getenv( "USER_NAME" ), System.getenv( "PASSWORD" ) );

    System.out.println( "Connecting Provider: " + providerString );

    Provider provider = peer.getProvider( providerString );

    provider.addObserver( handler );

    // Wait for ProvInServiceEv
    System.out.println( "Awaiting ProvInServiceEv..." );

    handler.providerInService.waitTrue();

    // Retrieve and open the Address (line) object for the 'from' DN specified in the environment
    CiscoAddress fromAddress = (CiscoAddress) provider.getAddress( System.getenv( "CALL_FROM" ) );
...

where Hander.java is something like:

package com.cisco.jtapi.makecall;

import javax.telephony.*;
import javax.telephony.events.*;
import javax.telephony.callcontrol.*;
import com.cisco.jtapi.extensions.*;
import com.cisco.cti.util.Condition;

public class Handler implements

    ProviderObserver, 
    TerminalObserver, 
    AddressObserver, 
    CallControlCallObserver {

    public Condition providerInService = new Condition();
    public Condition terminalInService = new Condition();
    public Condition addressInService = new Condition();
    public Condition callActive = new Condition();

    public void providerChangedEvent( ProvEv[] events ) {

        if ( events != null ) {

            for ( int i = 0; i < events.length; i++ ) {

                System.out.println( "-->Received " + events[ i ] + " for: " + events[ i ].getProvider().getName() );

                switch ( events[ i ].getID() ) {

                    case ProvInServiceEv.ID:

                        providerInService.set();

                        break;
                }
            }
        }
    }
...

See here for a complete sample: https://github.com/CiscoDevNet/jtapi-samples

Upvotes: 0

Related Questions