powered by Jive Software

Log clear traffic with Smack 4.4.x

Hello, I’m trying to log network traffic between Smack and my XMPP server, but unfortunately I cannot have clear traffic despite settings:

config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setCompressionEnabled(false);

while establishing a connection.
I’m using “smack-java8” and “smack-tcp” libraries.

Using old Smack version (4.3.x) these 2 configs allow to have clear traffic but with this new version of Smack start TLS anyway.

Am I forgetting something?

It should be sufficient to call SmackConfiguration.DEBUG = true, no need to disable security.
See https://github.com/igniterealtime/Smack/blob/master/documentation/debugging.md for more information on how to debug smack and view stanza traces.

Paul is right - if you can prevent the need to disable encryption, you should do that.

That said, your example should work. I’ve written this minimalistic test client. When running against a server on my localhost, I can clearly see unencrypted data be exchanged when I inspect the traffic with tcpdump -i lo port 5222 -X

pom.xml (this defines the dependency to the Smack library that I’ve used)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>smack-tcp-example</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.igniterealtime.smack</groupId>
            <artifactId>smack-java8-full</artifactId>
            <version>4.4.2</version>
        </dependency>
    </dependencies>
</project>

TestClient.java:

import org.jivesoftware.smack.*;
import org.jivesoftware.smack.tcp.*;

public class TestClient {
    public static void main(String[] args) throws Exception {
        XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
                .setUsernameAndPassword("john", "secret")
                .setXmppDomain("example.org")
                .setHost("localhost")
                .setPort(5222)
                .setCompressionEnabled(false)
                .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
                .build();

        AbstractXMPPConnection conn = new XMPPTCPConnection(config);
        conn.connect().login();
    }
}

Hi, thank you for your replies!
I’m executing my Smack client in the same way, using Java 8.
I’m able to log clear traffic at the beginning, but later Smack client send tag and logs becomes encrypted.

See the attachment for more details on the behaviour:
Smack traffic log.log (10,0 KB)

What can be wrong?
Thank you again!

StartTLS is being negotiated by your client. Have you invoked .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled) on the configuration object that you’re using to set up the connection? I assume that this will prevent StartTLS from being started.

Thank you again for your patience, I’ve found the problem.
In my test project there was two Xmpp clients: the second one caused encrypted traffic.

I’m now able to log clear traffic with both Smack versions, 4.3.x and 4.4.x!