Search code examples
xmppsmackstream-management

Enable stream management xmpp connection smack 4.1


I tried enabling stream management(XEP-0198) by this piece of code

XMPPTCPConnectionConfiguration connConfig = XMPPTCPConnectionConfiguration.builder().setHost(HOST)
            .setPort(PORT).setDebuggerEnabled(true).setSecurityMode(SecurityMode.disabled)
            .setUsernameAndPassword(USERNAME, PASSWORD).setServiceName(SERVICE).build();

    XMPPTCPConnectionconnection = new XMPPTCPConnection(connConfig);

        connection.setPacketReplyTimeout(TIME_OUT);
        connection.connect();
        connection.login();
        connection.setUseStreamManagement(true);

But later when I check for stream management it returns false.


Solution

  • I guess you need to set stream management before connecting to xmpp.

    XMPPTCPConnectionConfiguration connConfig = XMPPTCPConnectionConfiguration.builder().setHost(HOST)
            .setPort(PORT).setDebuggerEnabled(true).setSecurityMode(SecurityMode.disabled)
            .setUsernameAndPassword(USERNAME, PASSWORD).setServiceName(SERVICE).build();
    
    XMPPTCPConnectionconnection = new XMPPTCPConnection(connConfig);
    
        connection.setUseStreamManagement(true);
        connection.setPacketReplyTimeout(TIME_OUT);
        connection.connect();
        connection.login();