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

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.

Code:

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

con.sendPacket(registration);

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

collector.cancel();

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?

Error it’s this one:

No response received within reply timeout. Timeout was 50000ms (~50s). Used filter: IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=Y7o04-486)), : fromFilter (OrFilter: (FromMatchesFilter (full): null, FromMatchesFilter (bare): user@myserver, FromMatchesFilter (full): myserver)).

user@myserver it’s the actually logged in user who has this error