Catching stream feature parsing exceptions

How is a user of Smack expected to catch exceptions that are thrown by org.jivesoftware.smack.AbstractXMPPConnection#parseFeatures?

For some reason, Spark only gets that right on the second connection attempt. It currently uses Smack 4.3.4.

The first attempt will have a result that suggests some kind of race (in this case, we’re trying to connect with disabled encryption, while the server is configured to require it. The expected behavior is for

SSL/TLS required by server but disabled in client

to be shown, but for a reason that I’ve yet to figure out, that happens in Spark only when you try to connect for a second time (or more). The first time either gives you a timeout, or returns

Client is not, or no longer, connected. Did you call connect() before login()?

That suggests some kind of race, but I’ve not been able to see where. There’s a lot of async stuff going on…

connection.connect() doesn’t block until after features are parsed, I think? How can I sync on that? I’ve tried using a connection listener, but that triggers ‘connected’ before it fails to parse features (and then triggers closedOnError)

The catch in parseAndProcessElement() should handles those exceptions by calling notifyConnectionError(). I did a lot of work on that part in Smack 4.4, as it is tricky to notify all interested parties of an error.

In Smack 4.4, and in the Smack’s current master, the SecurityRequiredByServerException is stored as currentSmackException, which should be eventually thrown by connection()/login().

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.