Hi,
I am using Smack 4.1.1 on Android with Tigase version 7.0.1 have the attached logic
for setting up the connection & login. When I disable the connection on Android device,
ReconnectionManager comes into play & successfully obtains the connection when I
re-enable the connection. During the period, the current device(i.e. the receiver) is offline,
if the sender sends messages(actual text) 1,2,3,4,5,6 on enabling the connection for receiver
messages 1,6,4,4,2,6 are received in the order written. I have tried this many times but the
order remains jumbled with duplicates. Although the number of messages received is always
same as the number of messages sent by the sender.
From server logs, it is clear that the server is correctly resuming the stream & is sending the
messages back in the right order with no message loss or duplication which implies that there
is something wrong with my logic. Can someone please take a look & guide.
static {
XMPPTCPConnection.setUseStreamManagementDefault(true);
XMPPTCPConnection.setUseStreamManagementResumptiodDefault(true);
}
SmackConfiguration.DEBUG = true;
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration
.builder()
.setHost(HOST)
.setPort(Integer.parseInt(PORT))
.setServiceName(SERVER)
.setSecurityMode(SecurityMode.disabled)
.setDebuggerEnabled(false)
.build();
XMPPTCPConnection connection = new XMPPTCPConnection(config);
ReconnectionManager.getInstanceFor(connection).enableAutomaticReconnection();
ServerPingWithAlarmManager.getInstanceFor(connection).setEnabled(true);
StanzaFilter filter = MessageTypeFilter.CHAT;
connection.addAsyncStanzaListener(new StanzaListener() {
@Override
public void processPacket(Stanza packet) {
…
}
}, filter);
connection.login(username, password, resource);
Presence presence = new Presence(Presence.Type.available);
presence.setMode(Presence.Mode.available);
connection.sendStanza(presence);
Thanks,
Aejaz