javasctpcapmobicents

How to detect SCTP connection failuer


I am using mobicents CAP implementation to build a CAP application for CAMEL charging; my application is working fine and I can send and receive messages between SSF and SCF. What I am looking for is: how to detect it the SCTP link between client and server has been broken? Because when I deliberately stop the server and keep the client running, on sending CAPDialog doesn't raise any error.

When I stop the server, on console I see following exception:

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)

And during this if I try to send a CAPDialog e.g. send an oAnswer event, it simple doesn't tell if the request was successful or not (which ideally should return a failure in my case)

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();

Solution

  • "capDialog.send();" code does not return back an error even when any underlying SS7 link is down.

    If you have access to SCTP stack you can check if SCTP connection is up or down: Association association = ...; association.isConnected();