当我打电话时:
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);
然后我有时会 一个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
我已经尝试将jtapi.ini中的JtapiPostConditionTimeout
增加到20秒(正如我在文档中看到的那样,它是最大值)。
我希望不会出现此异常。
但仅有时会出现此异常。
P.S。例外字段如下:
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:
答案 0 :(得分:0)
诸如提供者,地址,终端之类的对象具有服务中/服务中状态-打开一个状态(例如,通过添加观察者)将启动连接到CUCM CTI Manager并建立对对象的观察/控制的过程,但这需要一些时间。
通常,您将等待这些对象的服务中事件到达,然后再尝试对其进行任何操作:
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" ) );
...
其中Hander.java类似于:
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;
}
}
}
}
...
有关完整示例,请参见此处:https://github.com/CiscoDevNet/jtapi-samples