src/main/java/org/jivesoftware/smack/XMPPConnection.java
private boolean useCompression() {
        // If stream compression was offered by the server and we want to use
        // compression then send compression request to the server
        if (authenticated) {
            throw new IllegalStateException(
                    "Compression should be negotiated before authentication.");
        }

        if ((compressionHandler = maybeGetCompressionHandler()) != null) {
            requestStreamCompression(compressionHandler.getCompressionMethod());
            // Wait until compression is being used or a timeout happened
            synchronized (this) {
                try {
                    this.wait(SmackConfiguration.getPacketReplyTimeout() * 5);
                } catch (InterruptedException e) {
                    // Ignore.
                }
            }
            return isUsingCompression();
        }
        return false;
    }
private boolean useCompression() {
        // If stream compression was offered by the server and we want to use
        // compression then send compression request to the server
        if (authenticated) {
            throw new IllegalStateException(
                    "Compression should be negotiated before authentication.");
        }

        if ((compressionHandler = maybeGetCompressionHandler()) != null) {
            requestStreamCompression(compressionHandler.getCompressionMethod());
            // Wait until compression is being used or a timeout happened
            synchronized (this) {
                try {
                    this.wait(SmackConfiguration.getPacketReplyTimeout() * 5);
                } catch (InterruptedException e) {
                    // Ignore.
                }
            }
            return isUsingCompression();
        }
        return false;
    }
Starts using stream compression that will compress network traffic.
Traffic can be reduced up to 90%. Therefore, stream compression is ideal
when using a slow speed network connection. However, the server and the
client will need to use more CPU time in order to un/compress network
data so under high load the server performance might be affected.
<p>
<p/>
Stream compression has to have been previously offered by the server.
Currently only the zlib method is supported by the client. Stream
compression negotiation has to be done before authentication took place.
<p>
<p/>
Note: to use stream compression the smackx.jar file has to be present in
the classpath.

@return true if stream compression negotiation was successful.