Search code examples
androidxmppopenfiresmack

How to force Openfire to request ack when sending message to clients and if none, returned save as offline


I hope you are having a nice day. We waited a long time for Openfire to implement the StreamManagement capability, and now we have it running. However, the real problem scenario of packet loss in Openfire still remained the same.

The client disconnects from the internet but since it was before Openfire sent its next ping, the server assumes that the client is connected and sends the message, which apparently happens without requesting ack from the client. So, if it didn't send any, save it as offline.

I have tried many things to fix this (played around with StreamManagement and _Resumption_) and the last thing I can think of is to write a plugin in the server side and do everything about storing offline messages, manually, which is going to take a long time. But I still imagine this should have a solution, otherwise, Openfire is useless, isn't it? Can someone please help me if there is any solution to this? Thanks a lot.

Plus, I wonder, doesn’t Openfire use TCP to stay alive? So, shouldn’t it notice whenever the client disconnects instantly?

My way of initiating the connection with smack:

 connInter.getConnection().setReplyTimeout(15000);

    connInter.getConnection().setUseStreamManagement(true);
    //connInter.getConnection().strea
    connInter.getConnection().setUseStreamManagementResumption(true);

    registerReceiver(mConnReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));

    DeliveryReceiptManager
        .getInstanceFor(connInter.getConnection())
            .setAutoReceiptMode(AutoReceiptMode.always);

    ReconnectionManager.setEnabledPerDefault(false);

    SASLMechanism mechanism = new SASLDigestMD5Mechanism();
    SASLAuthentication.registerSASLMechanism(mechanism);
    // SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1");
    SASLAuthentication.unBlacklistSASLMechanism("DIGEST-MD5");

    PingManager.setDefaultPingInterval(180);

Solution

  • This is a BUG check it here:

    https://issues.igniterealtime.org/browse/OF-963

    This is official Bug in Openfire. You can set time interval after which user is set to offline. But in versions > 4.0.2 there is bug where client is always online regardless the time interval u set. I use older version exactly 4.0.2 for my Openfire installation as this BUG is not fixed yet.

    This is the reason why messages are sent from another client and lost, cause first client appear as online and in reality it is not and message never get receipt for delivery.