I am using Smack V4.4.1. When I close a previously opened XMPP connection by calling XMPPTCPConnection.disconnect(), I get the following exception:
Mar 08, 2021 4:44:52 PM org.jivesoftware.smack.AbstractXMPPConnection waitForClosingStreamTagFromServer
INFO: Exception while waiting for closing stream element from the server XMPPTCPConnection[85744@eu92b-fin002.labalz.aeat.allianz.at/AgentID@85744] (0)
org.jivesoftware.smack.SmackException$SmackWrappedException: org.jivesoftware.smack.xml.XmlPullParserException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[82,231]
Message: XML document structures must start and end within the same entity.
at org.jivesoftware.smack.AbstractXMPPConnection.setCurrentConnectionExceptionAndNotify(AbstractXMPPConnection.java:690)
at org.jivesoftware.smack.AbstractXMPPConnection.notifyConnectionError(AbstractXMPPConnection.java:994)
at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$4100(XMPPTCPConnection.java:130)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1152)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:913)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:936)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.jivesoftware.smack.xml.XmlPullParserException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[82,231]
Message: XML document structures must start and end within the same entity.
at org.jivesoftware.smack.xml.stax.StaxXmlPullParser.next(StaxXmlPullParser.java:194)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1140)
… 3 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[82,231]
Message: XML document structures must start and end within the same entity.
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:652)
at org.jivesoftware.smack.xml.stax.StaxXmlPullParser.next(StaxXmlPullParser.java:192)
… 4 more
The exception comes from XMPPTCPConnection.shutdown(false) after calling waitForClosingStreamTagFromServer().
My code for opening the XMPP connection is the following:
Could be that the server is not terminating the stream with a closing stream tag. Hard to tell without further data. Enable SmackConfiguration.DEBUG and retrieve an XMPP trace of the connection.
I don’t see any additional packets after the call of XMPPTCPConnection.waitForClosingStreamTagFromServer() in Smack Debug Window/Raw Recieved Packets. The last packet, that was received before the call was:
The server should response to a closing stream tag from the client with a clean stream shutdown. Could be possible that this is not the case, check the server log if one is send, and if not, report this to your server vendor.
Just to clarify: This does not cause any issues for you, or does it? As far as I can tell, you merely see a logged exception, recorded with ‘info’ log level.
The server is a Cisco Finesse server. For failsafe operation, we have two Finesse servers running. When the ConnectionListener.connectionClosedOnError() is triggered, we switch to the other server. But during the switch (where we call XMPPConnection.disconnect()) this issue calls the listener again and we end up switching the servers until we give up. So it seems I have to build a workaround for that.
This is the exception:
org.jivesoftware.smack.xml.XmlPullParserException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[82,4153]
Message: XML document structures must start and end within the same entity.
at org.jivesoftware.smack.xml.stax.StaxXmlPullParser.next(StaxXmlPullParser.java:194)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1140)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:913)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:936)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[82,4153]
Message: XML document structures must start and end within the same entity.
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:652)
at org.jivesoftware.smack.xml.stax.StaxXmlPullParser.next(StaxXmlPullParser.java:192)
… 4 more