AnsweredAssumed Answered

Smack API - client broken on timeout IQ result-error, how to avoid? (bookmarkManager involved)

Question asked by Oibaf Olsen on Jul 15, 2016
Latest reply on Jul 15, 2016 by Oibaf Olsen

Hello all,

I have developed a Spark-like client with Smack API (2.7.7) connected on Openfire 4.0.2.


My issue: when I use BookmarkManager to add a Bookmarks, sometimes I recive a timeout that litteraly broke the client.




BookmarkManager.getBookmarkManager(XmppManager.getInstance().getConnection()).ad dBookmarkedConference(mucSubject,

  mucRoom, true, myDisplayName,  password);



Timeout error:

(atm can't paste, but it's the common timeout error, timeout it's setted up as 50 seconds)



I don't know how to handle this timeout and ignore/do something else when occours.

For sure, what I get is that thread-sequence broke and client starts to have unpredictable behaviour.



Any idea and explanation?



I've found this code in Spark but I didn't really understaind how to use a PacketCollector, I'm pretty sure I miss something important (for custom IQ I just register a StanzaListener addAsyncStanzaListener); more, if no result, I'd like to continue with some other operations



        PacketCollector collector = con.createPacketCollector(new PacketIDFilter(registration.getPacketID()));


        IQ response = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());


        if (response == null) {

            throw new XMPPException("Server timed out");


        if (response.getType() == IQ.Type.ERROR) {

            throw new XMPPException("Error registering user", response.getError());




More: bookmark are however "slow" compared to other actions, it's that normal?