powered by Jive Software

Send xml unescaped message, makes me "unavailable", Why?


If i send string unescaped message via smack, immediatly my presence goes to ***unavailable. ***

I know i should unescape my message and send. But if did by mistake why should my presence change?

Please help me to fix the problem ASAP.

I am using

smack 3.1.0

openfire 3.7.0

The error msg i got in log:

[Fatal Error] :1:722: The entity name must immediately follow the ‘&’ in the entity reference.

ERROR: ‘The entity name must immediately follow the ‘&’ in the entity reference.’

** Transformation error

  • org.xml.sax.SAXParseException: The entity name must immediately follow the ‘&’ in the entity reference.*

org.xml.sax.SAXParseException: The entity name must immediately follow the ‘&’ in the entity reference.

  • at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXP arser.java:1231)*

  • at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity( TransformerImpl.java:609)*

  • at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Transfor merImpl.java:707)*

  • at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Transfor merImpl.java:313)*

  • at org.jivesoftware.smackx.debugger.EnhancedDebugger.formatXML(EnhancedDebugger.ja va:874)*

  • at org.jivesoftware.smackx.debugger.EnhancedDebugger.access$1700(EnhancedDebugger. java:65)*

  • at org.jivesoftware.smackx.debugger.EnhancedDebugger$21.run(EnhancedDebugger.java: 835)*

  • at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)*

  • at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)*

  • at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:26 9)*

  • at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)*

  • at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:17 4)*

  • at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)*

  • at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)*

  • at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)*

I guess the server disconnects you, because you send invalid, unescaped, XMPP stanzas.

Thanks Flow,

I REALISED, that i am sending unescaped, XMPP stanzas is the problem. What i want is, Is there any way i can handle this error? Is there a way to avoid disconnets?

It’s the server who is disconnecting you, not the client XMPP library, therefore this question is not really suited for the Smack forum.

And any sane XMPP server implementation will always terminate a XMPP connection that sends invalid, malformed stanzas for security reasons. I wonder why you don’t consider doing the right thing, escaping the data? Smack has a convenient method for this: StringUtils.escapeForXML()

I already escaped the string, which i want to send. I just thinking, why there is no handler for invalid stanzas or implicitly handle or auto unescape? Anyway i have to ask this question(disconnect) in operfire fourm.


I think I gave you the answer already: Because there is no reliable way to recover from an invalid stanza. So the only secure way is to terminate the connection.


So, will autoreconnect work for this situation or i have to reconnect manually?

In otherwords can i handle it in ConnectionListener.connectionClosedOnError and reconnect? (i dont think so, bcoz parameter is Exception not Error and presence goes to “unavailabe” not disconnect from server).