如何检测SCTP连接失败

时间:2015-04-14 05:21:42

标签: java sctp cap mobicents

我正在使用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();

1 个答案:

答案 0 :(得分:1)

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

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