XML Debugger is not working with Openfire 4.x

Openfire ships with an “xmldebugger” plugin; that’s no longer working with Openfire 4, probably because of a change in startup order. The fix is to delay the initialisation until the plugin manager has completed.

To fix this, in org.jivesoftware.openfire.plugin.DebuggerPlugin, replace the existing initializePlugin(…) method with the following two (apologies about the formatting, it’s got a little awry in the cut’n’paste).

public void initializePlugin(PluginManager pluginManager, File pluginDirectory) {

if (pluginManager.isExecuted()) {

addInterceptors();

} else {

pluginManager.addPluginManagerListener(new PluginManagerListener() {

public void pluginsMonitored() {

// Stop listening for plugin events
pluginManager.removePluginManagerListener(this);

// Start listeners
addInterceptors();

}

});

}

}

private void addInterceptors() {

// Add filter to filter chain builder
ConnectionManagerImpl connManager = (ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager();

defaultPortFilter = new RawPrintFilter(“C2S”);

SocketAcceptor socketAcceptor = connManager.getSocketAcceptor();

if (socketAcceptor != null) {

socketAcceptor.getFilterChain().addFirst(“rawDebugger”, defaultPortFilter);

}

oldPortFilter = new RawPrintFilter(“SSL”);

SocketAcceptor sslAcceptor = connManager.getSSLSocketAcceptor();

if (sslAcceptor != null) {

sslAcceptor.getFilterChain().addFirst(“rawDebugger”, oldPortFilter);

}

componentPortFilter = new RawPrintFilter(“ExComp”);

SocketAcceptor componentAcceptor = connManager.getComponentAcceptor();

if (componentAcceptor != null) {

componentAcceptor.getFilterChain().addFirst(“rawDebugger”, componentPortFilter);

}

multiplexerPortFilter = new RawPrintFilter(“CM”);

SocketAcceptor multiplexerAcceptor = connManager.getMultiplexerSocketAcceptor();

if (multiplexerAcceptor != null) {

multiplexerAcceptor.getFilterChain().addFirst(“rawDebugger”, multiplexerPortFilter);

}

interpretedPrinter = new InterpretedXMLPrinter();

if (JiveGlobals.getBooleanProperty(“plugin.debugger.interpretedAllowed”)) {

// Add the packet interceptor that prints interpreted XML
InterceptorManager.getInstance().addInterceptor(interpretedPrinter);

}

// Listen to property events
PropertyEventDispatcher.addListener(this);

}

I have installed Debugger plugin and enabled it in System Properties. After i have started Openfire (4.0.2) it started printing xml into launcher window:

Openfire 4.0.2 [Jun 17, 2016 12:53:30 PM]

Admin console listening at:

http://wroot:9090

https://wroot:9091

Starting Bookmarks Plugin

Starting Client Control Plugin

Starting Fastpath Server

Starting Monitoring Plugin

INTERPRETED: Exodus

INTERPRETED:

INTERPRETED:

INTERPRETED:

INTERPRETED: <feature var="http://jabber.org/protocol/pubsub#persis

etc.

Setting the property will enable the plugin (it has a property listener in case it’s enabled after startup).

What happens if you restart OF (and don’t change the property, leaving it enabled) ?

Sam after Openfire restart. It starts printing xml when i login with a client.

Odd; that’s not what I was seeing with Openfire 4.0.1 (single node, with Hazelcast-based clustering enabled)

The system property i’ve set to true is plugin.debugger.interpretedAllowed

OK, but about the non-interpreted interceptors? e.g. the C2S Raw Print Filter? I found that during startup, connManager.getSocketAcceptor() was returning null, until I delayed it until after the plugin manager had completed execution.

I have just installed Openfire 3.10.3 with debugger plugin 1.4.0 in a test machine and it doesn’t print anything if you don’t set an interpret property. Behaves the same as with 4.0.2 version.

Yessssss… Looking at this closer, it seems that the RawPrintFilter was broken in release 1.4.0 ; it’s checking for an “instanceof ByteBuffer” when it looks like it should be an instance of IoBuffer with Mina 2.x; as it’s a more significant change I’ll try and get proper patch out (but probably not until next week) with all the changes in.

FWIW, the RawPrintFilter shows the complete stream, including the login sequence, which the InterpretedXMLPrinter doesn’t show.

Greg

Greg,

You are using version 1.5.0 right?

I was able to reproduce old behavior with Openfire 3.9.3 and 1.3.0 version of plugin. Filed as [OF-1152] XmlDebugger not printing non-interpreted xml traffic - IgniteRealtime JIRA

If you are familiar with GitHub it would be better to submit your patch as a pull request there and link to this ticket. GitHub - igniterealtime/Openfire: A XMPP server licensed under the Open Source Apache License.

OK, there’s a pull request @ OF-1152: Ensure that raw XML is logged; by GregDThomas · Pull Request #603 · igniterealtime/Openfire · GitHub which fixes it. Let me know if there are any issues with it,

Greg

Thanks. I think Guus will take it over from here, he already has a few questions (on Github).