Reputation: 8357
I'm using aSmack library in my android app for group chatting, my problem is that sometimes when the connection is lost, ReconnectionManager fails to reconnect and gives this error:
java.lang.IllegalThreadStateException: Thread already started.
at java.lang.Thread.start(Thread.java:1045)
at org.jivesoftware.smack.PacketWriter.startup(PacketWriter.java:119)
at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:603)
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:565)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:991)
at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:122)
and here's my code:
// Create a connection
ConnectionConfiguration config = new ConnectionConfiguration(HOST, PORT);
config.setSASLAuthenticationEnabled(false);
config.setDebuggerEnabled(true);
config.setReconnectionAllowed(true);
Any Ideas on how to avoid this error? or maybe use a different asmack version, I'm currently using asmack-2010.05.07.jar
Upvotes: 1
Views: 503
Reputation: 8357
I found the solution, it was a bug in aSmack, reconnect()
method in ReconnectionManager
class must by synchronized
to avoid this exception, Now I'm using asmack-android-19-0.8.10.jar and it has this fix.
Upvotes: 1