powered by Jive Software

Mutually exclusive messages logged while session being closed

The following was logged by Smack 4.4.0-alpha2 when the server disconnected Smack.

Smack first logs that it receives a closing element, then it logs “this could happen e.g. if the server closed the connection without sending a closing stream element”. Those two seem mutually exclusive. Does this hint at a larger issue?

Nov 15, 2019 8:27:48 PM org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader parsePackets
INFO: XMPPTCPConnection[leela@laptop-guus/client-1] (0) received closing </stream> element. Server wants to terminate the connection, calling disconnect()

20:27:48.441 client-1: Send: <presence xmlns='jabber:client' id='TSVEF-15' type='unavailable'></presence>

Nov 15, 2019 8:27:48 PM org.jivesoftware.smack.AbstractXMPPConnection waitForClosingStreamTagFromServer
INFO: Exception while waiting for closing stream element from the server XMPPTCPConnection[leela@laptop-guus/client-1] (0)
org.jivesoftware.smack.SmackException$SmackMessageException: Parser got END_DOCUMENT event. This could happen e.g. if the server closed the connection without sending a closing stream element
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1136)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:882)
	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:902)
	at java.lang.Thread.run(Thread.java:748)
1 Like

I have the same problem in our android application. When the user logins and get this exception, the user should close the program and then relaunch it.

Yep it looks like Smack is waiting for the closing stream element even in the case it was the server we initiated the stream termination by sending it in the first place.

I’ll look into it.

Are you sure that you have the same problem? This is about an exception on stream termination, not initiation.

Yes I am sure. When the user close app and relogin . We got exception server wants to terminate session. then the user should close the app and relaunch again. Sometimes the connection is authenticated when we send for example Iq stanza , It is not sent . after a seconds we get “Exception while waiting for closing stream element from the server” .

I had a closer look and I suspect that the server may closes the TCP connection without waiting for the closing stream tag from the client (while it is supposed to). Could you verify that this is the case?

I also thought openfire closes the session without any reason. I have noticed also that apache mina in openfire is the cause of this disconnection. Now we are modifying openfire to switch from apache mina to netty.

1 Like

Please consider upstreaming your changes, so more users can benefit from your efforts :wink: .

1 Like