Quantcast
Viewing all articles
Browse latest Browse all 4979

Having problem in enabling Stream Management in smack 4.1.1

I have search every for the method used in enabling stream management in smack and nothing is working for me

 

This function isSmAvailable() always return false, am using prosody as the XMPP server in which the smacks[mod_smacks] is installed and enabled below is my code

 

 

XMPPTCPConnectionConfiguration.Builder configureBuilder = XMPPTCPConnectionConfiguration.builder();
configureBuilder.setServiceName(Config.XMPP_HOST);
configureBuilder.setHost(HOST);
//configureBuilder.allowEmptyOrNullUsernames();
configureBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);


//configureBuilder.setDebuggerEnabled(true);
SmackConfiguration.DEBUG = true;
xmppConnection = new XMPPTCPConnection(configureBuilder.build());
Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);




XMPPTCPConnection.setUseStreamManagementResumptiodDefault(true);
//PingManager
xmppConnection.setUseStreamManagement(true);
xmppConnection.setUseStreamManagementResumption(true);

ReconnectionManager reconnectionManager = ReconnectionManager.getInstanceFor(xmppConnection);
reconnectionManager.enableAutomaticReconnection();


try {

  MyLog.w("Connecting to xmpp server");
   xmppConnection.setPacketReplyTimeout(100000);
   xmppConnection.connect();
   //xmppConnection.sendSmAcknowledgement();


   if (xmppConnection.isSmEnabled()) {

  MyLog.w("stream M is enabled");
   } else {

  MyLog.w("stream M is not enabled");
   }

 

 

   if (xmppConnection.isSmAvailable()) {

  MyLog.w("stream M available");
   } else {

  MyLog.w("stream M is not available");
   }

 

   //xmppConnection.
   xmppConnection.addConnectionListener(new ConnectionListener() {

   @Override
   public void connected(XMPPConnection xmppConnection) {

   //logger.warning("Connected to server successfully");
   MyLog.w("Connected to server");
   }

 

   @Override
   public void authenticated(XMPPConnection xmppConnect, boolean b) {

   //logger.warning("Nice it is authenticated too");
   MyLog.w("Finally logged into the server");

   }

 

   @Override
   public void connectionClosed() {

   //logger.warning("Connected to server failed");
   }

 

   @Override
   public void connectionClosedOnError(Exception e) {

   //logger.warning(e.getMessage());
   MyLog.w("Connection close on error" + e.getMessage());
   }

 

   @Override
   public void reconnectionSuccessful() {

   //I think here we need to relogin the user
   MyLog.w("Reconnected successfully ....thanks to RC");
   }

 

   @Override
   public void reconnectingIn(int i) {

 

  }

 

   @Override
   public void reconnectionFailed(Exception e) {

  MyLog.w("Reconnection Failed " + e.getMessage());
   }

  });
} catch (Exception e) {

  MyLog.w("connected-error" + e.getMessage());
}

 

 

I tried adding streamFeature for stream management using

 

xmppConnection.addStreamFeature() but it tells me that the function is private

 

and also through ProviderManager.addStreamFeature(element, namespace, provider) is also not working

 

Can you please help me to figure this out or there is something am doing wrong here

 

Thanks


Viewing all articles
Browse latest Browse all 4979

Trending Articles