powered by Jive Software

Smack reconnect race condition

Hi,

There seems to be a problem in the Smack 3.0.4 reconnection manager. I have a batch command that logs in to a OpenFire server and then waits for messages.

Occasionally the network could go down, so I’m listening for reconnect messages.

I’m seeing the following when I log those:

INFO [ ]: reconnecting in 5
INFO [ ]: reconnecting in 5
INFO [ ]: reconnecting in 9
INFO [ ]: reconnecting in 4
INFO [ ]: reconnecting in 4
INFO [ ]: reconnecting in 8
INFO [ ]: reconnecting in 3
INFO [ ]: reconnecting in 3
INFO [ ]: reconnecting in 7
INFO [ ]: reconnecting in 2
INFO [ ]: reconnecting in 2
INFO [ ]: reconnecting in 6
INFO [ ]: reconnecting in 1
INFO [ ]: reconnecting in 1
INFO [ ]: reconnecting in 5
INFO [ ]: reconnecting in 0
INFO [ ]: reconnecting in 0

There seems to be more than one thread trying to reconnect (my batch is single threaded). If that happens, Smack is not able to correct reconnect to the server. It claims to successfully reconnect, but seems to be stepping onto itself shortly thereafter:

INFO [ ]: reconnection successful

INFO [ ]: WRITING:
INFO [ ]: WRITING:
java.io.IOException: Stream closed
at java.io.BufferedWriter.ensureOpen(BufferedWriter.java:98)
at java.io.BufferedWriter.write(BufferedWriter.java:203)
at java.io.Writer.write(Writer.java:126)

Sometimes I get

INFO [ ]: reconnection successful
java.lang.NullPointerException
at org.jivesoftware.smack.SASLAuthentication.send(SASLAuthentication.java:409)
at org.jivesoftware.smack.sasl.SASLMechanism.authenticate(SASLMechanism.java:68)
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 194)
at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:341)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1287)
at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:163)

Has anyone seen this before ? Any hints on how to address it or if that might have been fixed in the subversion trunk already ?

Thanks in advance,

  • Filip

I have the same problem now.

Having received this:

stream:error (text)

at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:260)

at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)

at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)

The client try to reconntect and sometimes, it does not succeed at all…

Any idea how to prevent this?

Thank you in advance!