我尝试通过这段代码启用流管理(XEP-0198)

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);

但是稍后,当我检查流管理时,它返回false。

最佳答案

我想您需要在连接到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();

关于xmpp - 启用流管理xmpp连接smack 4.1,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31330991/

10-09 18:34