问题
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.
回答1:
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();
来源:https://stackoverflow.com/questions/31330991/enable-stream-management-xmpp-connection-smack-4-1