我正在使用mobicents CAP实现来构建用于CAMEL收费的CAP应用程序;我的应用程序运行正常,可以在SSF和SCF之间发送和接收消息。
我正在寻找的是:如何检测到它,客户端和服务器之间的SCTP链接已断开?因为当我故意停止服务器并保持客户端运行时,发送CAPDialog不会引发任何错误。

当我停止服务器时,在控制台上我看到以下异常:

2015-04-14 13:15:29,669 [Thread-0 ] ERROR org.mobicents.protocols.sctp.SelectorThread - Exception while finishing connection for Association=clientAsscoiation
java.net.ConnectException: Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
    at org.mobicents.protocols.sctp.SelectorThread.finishConnectionTcp(SelectorThread.java:407)
    at org.mobicents.protocols.sctp.SelectorThread.finishConnection(SelectorThread.java:368)
    at org.mobicents.protocols.sctp.SelectorThread.run(SelectorThread.java:151)
    at java.lang.Thread.run(Unknown Source)


在此期间,如果我尝试发送CAPDialog例如发送一个oAnswer事件,它很简单地不会告诉您请求是否成功(理想情况下应返回失败)

OAnswerSpecificInfo oAnswerSpecificInfo = this.getCapProvider().getCAPParameterFactory().createOAnswerSpecificInfo(null,
                    false, false, null, null, null);
ReceivingSideID legID = this.getCapProvider().getCAPParameterFactory().createReceivingSideID(LegType.leg2);
MiscCallInfo miscCallInfo = this.getCapProvider().getINAPParameterFactory().createMiscCallInfo(MiscCallInfoMessageType.notification, null);
EventSpecificInformationBCSM eventSpecificInformationBCSM = this.getCapProvider()
                    .getCAPParameterFactory()
                    .createEventSpecificInformationBCSM(oAnswerSpecificInfo);

 CAPDialogCircuitSwitchedCall capDialog = (CAPDialogCircuitSwitchedCall) getCapProvider().getCAPDialog(localDialogId);

 capDialog.addEventReportBCSMRequest(EventTypeBCSM.oAnswer, eventSpecificInformationBCSM, legID, miscCallInfo, null);
 capDialog.setUserObject(getParamAsString("referenceId"));
 capDialog.setReturnMessageOnError(true);
 capDialog.send();

最佳答案

“ capDialog.send();”即使任何基础的SS7链接断开,代码也不会返回错误。

如果您有权访问SCTP堆栈,则可以检查SCTP连接是打开还是关闭:
关联关联= ...;
association.isConnected();

10-08 13:15