Closed wichert closed 5 years ago
For reference: we had a case today where this happened due to an exception being thrown in a plugin.
The expected (and standard) behavior if the XML is incorrect is for the Connection to send a stream error and close the socket. Anything else is a bug. Could you provide a test case to reproduce?
In our case the XML was correct. But because a xmpp.js plugin failed and threw an exception xmpp.js left the parser in the wrong state. This resulted in xmpp.js then failing to parse the next message coming in, and closing the connection.
I see.
Could you provide a simple test case to reproduce and explore options?
The Connection class roughly works like this:
Connection.open()
aParser
instance is createdConnection._onData()
is called, which writes it to the parserNow something can go wrong during the parsing or processing of the message. If that happens the parser is left in an inconsistent state, which results in all future messages failing to parse.
Since every message is a complete XML fragment the code should make sure it always starts with a clean parser state when it starts parsing a new message, or it should create a new parser for every message.