I checked out similar questions But I could not solve my problem.
I implemented a chat app using Smack 4.2.
The strange thing is that I can only receive chat messages if I send one one first.
Here is my connection code:
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setHost(HOST)
.setPort(PORT)
.setXmppDomain(serviceName)
.setUsernameAndPassword(USERNAME + "@"+HOST, PASSWORD)
.setCompressionEnabled(false)
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setSendPresence(true)
.build();
connection = new XMPPTCPConnection(config);
connection.connect();
connection.login();
And this is how I send the message:
final Message msg = new Message();
msg.setTo(jid);
msg.setFrom(myjid);
msg.setBody(message.getText().toString());
msg.setStanzaId(rd);
msg.setType(Message.Type.chat);
connection.sendStanza(msg);
How can I receive a message even BEFORE I send one to the other user ?
Thanks!!!
SOLVED
I cannot believe I wasted so much time on this. The problem is that Smack 4.2.0 is buggy (it's a beta version after all). All I needed to do is use Smack 4.1.9 instead.