Comment #6 on issue 2254 by jean.deruelle: Provide a way in MSS to support keepalives and cleanup for client-initiated connections per RFC 5626
http://code.google.com/p/mobicents/issues/detail?id=2254

Regarding 2) I will add it to the stack

Regarding 1) To be able to truly support the RFC in a correct way with handling of Flow-Timer headers by the application, adding sendHeartbeat(String ipAddress, int port) to the SipConnector class should do it but we may need to add 2 new listener methods - onKeepAliveResponse and onKeepAliveTimeout - to the SipConnectorListener interface to be notified of a response (pong) or the absence of a response (within 10s as defined per the RFC) - so that the application can send another keepalive for its chosen keepalive frequency or kill the inactive reliable (TCP/TLS) connections for a given ipaddress and port - through a new method killReliableConnection(String ipAddress, int port) -

So basically the application code would look like this


public class KeepAliveSender implements
                SipConnectorListener {
        private static Logger logger = Logger
                        
.getLogger(ShootmeSipServletAuthServletContextListener.class);

        public static final long KEEP_ALIVE_TIME = 120;
        public static Timer keepAliveTimer = new Timer();
        
        public void sipConnectorAdded(SipConnector connector) {
                // TODO Auto-generated method stub
                
        }

        public void sipConnectorRemoved(SipConnector connector) {
                // TODO Auto-generated method stub
                
        }
        
public void onKeepAliveResponse(final SipConnector sipConnector, final String ipAddress, final int port) {
                TimerTask sendKeepAliveTask = new TimerTask() {                 
                        @Override
                        public void run() {
                                sendHeartBeat(sipConnector, ipAddress, port);
                        }
                };
                keepAliveTimer.schedule(sendKeepAliveTask, KEEP_ALIVE_TIME);
        }
        
public void onKeepTimeout(SipConnector sipConnector, String ipAddress, int port) {
                sipConnector.killReliableConnection(ipAddress, port);
        }
        
public void sendHeartBeat(SipConnector sipConnector, String ipAddress, int port) {
                sipConnector.sendHeartBeat(ipAddress, port);
        }
}

What do you think, would that suit your use case ?

Reply via email to