Search in sources :

Example 26 with StreamError

use of org.xmpp.packet.StreamError in project Openfire by igniterealtime.

the class ConnectionHandler method exceptionCaught.

@Override
public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
    Log.warn("Closing connection due to exception in session: " + session, cause);
    try {
        // OF-524: Determine stream:error message.
        final StreamError error;
        if (cause != null && (cause instanceof XMLNotWellFormedException || (cause.getCause() != null && cause.getCause() instanceof XMLNotWellFormedException))) {
            error = new StreamError(StreamError.Condition.not_well_formed);
        } else {
            error = new StreamError(StreamError.Condition.internal_server_error);
        }
        final Connection connection = (Connection) session.getAttribute(CONNECTION);
        // OF-1784: Don't write an error when the source problem is an issue with writing data.
        if (JiveGlobals.getBooleanProperty("xmpp.skip-error-delivery-on-write-error.disable", false) || !(cause instanceof WriteException)) {
            connection.deliverRawText(error.toXML());
        }
    } finally {
        final Connection connection = (Connection) session.getAttribute(CONNECTION);
        if (connection != null) {
            connection.close();
        }
    }
}
Also used : WriteException(org.apache.mina.core.write.WriteException) StreamError(org.xmpp.packet.StreamError) Connection(org.jivesoftware.openfire.Connection)

Aggregations

StreamError (org.xmpp.packet.StreamError)26 ClientSession (org.jivesoftware.openfire.session.ClientSession)7 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)7 JID (org.xmpp.packet.JID)6 IOException (java.io.IOException)5 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)5 DocumentException (org.dom4j.DocumentException)5 Element (org.dom4j.Element)5 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)5 XmlPullParser (org.xmlpull.v1.XmlPullParser)5 Logger (org.slf4j.Logger)4 Socket (java.net.Socket)3 SSLException (javax.net.ssl.SSLException)3 PacketException (org.jivesoftware.openfire.PacketException)3 LocalClientSession (org.jivesoftware.openfire.session.LocalClientSession)3 IQ (org.xmpp.packet.IQ)3 StringprepException (gnu.inet.encoding.StringprepException)2 XMPPPacketReader (org.dom4j.io.XMPPPacketReader)2 AuthToken (org.jivesoftware.openfire.auth.AuthToken)2 UnknownStanzaException (org.jivesoftware.openfire.multiplex.UnknownStanzaException)2