Hi,
I’m developing an IoT project using Raspberry Pi 3 and Smack 4.2.1. I decided to setup my own XMPP chat server and I’ve selected eJabberd for this. Server version I’m currently using is 17.0.1.
I’ve build application which is used to communicate with the server in order to control the device and I’m having issues with reconnecting to the server when server goes down for some reason and then comes back again. Actually, problems occurs when server goes down 2nd time during the same XMPP session (I’m testing some server settings and I manually stop and start eJabberd server).
Basically, in my application I setup connection and ReconnectionManager and then connect and login to the server. All works perfectly. When I stop the server, Smack immediately recognizes disconnection and starts counting timeout to reconnect and repeats reconnection procedure as long as server is down. When I start the server, Smack succeeds to reconnect first time and then everything is ok with the connection. If I stop the server for the 2nd time during same XMPP session, Smack again recognizes disconnection and starts reconnecting procedure, but when I start the server again, this time Smack cannot reconnect successfully to the server. This time I’m getting errors.
At first, when Smack tries to reconnect, I’m getting “connected” event from my connection object and after that I get “reconnectionFailed” event from ReconnectionManager. Then comes longer pause and then I get exception described below:
14:02:09 Reconnection failed due to an exception (XMPPTCPConnection[***@***/***] (0))org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). While waiting for successful SASL authentication
at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:93)
at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:224)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.loginInternal(XMPPTCPConnection.java:386)
at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:493)
at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:450)
at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:254)
at java.lang.Thread.run(Thread.java:745)
And then as final I get “connectionClosedOnError” event from connection object with these 2 exceptions:
okt 25, 2017 2:02:54 PM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener
WARNING: Connection XMPPTCPConnection[***@***/***] (0) closed with error
java.lang.NullPointerException
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1194)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:982)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:998)
at java.lang.Thread.run(Thread.java:745)
14:02:54 XMPPConnection closed due to an exception (XMPPTCPConnection[***@***/***] (0))java.lang.NullPointerException
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1194)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:982)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:998)
at java.lang.Thread.run(Thread.java:745)
From this moment, my connection object always says it is connected and I cannot login to the server at all. As a workaround I can catch this NoResponseException and then create new connection object and connect to the server with it.
Is this a Smack bug or did I forget to setup something with my connection?
Thanks in advance