powered by Jive Software

Cannot receive message using Smack


I am trying to develop a chat application for android and iOS in which I am using OpenFire as the chat server. OpenFire has already been setup on AWS. But I am facing a problem here. I cannot receive messages using Smack.

Also I need to know that if I receive messages using Smack then does it retrieves all messages in one go or it sends the latest message, when this receive API is called.

I am using this to get messages function not returning message list,

i am able to send message to server but cant receive message list.

ChatManager chatmanager = con.getChatManager();

Chat newChat = chatmanager.createChat(“user4@jmj-pc”,null);

newChat.addMessageListener(new MessageListener() {


public void processMessage(Chat chat, Message message) {

System.out.println("Received message: " +message.getBody());



try {

newChat.sendMessage(“message body, jmj!”);


catch (XMPPException e) {

System.out.println(“Error Delivering block”);



Have you solved the problem? I got the same problem with you. If you have solved that, could you share your resolution please?

There is also one more trick to catch all message of all user

create a class which should implement ChatManagerListener

public class ChatManager implements ChatManagerListener {


public void chatCreated(Chat chat, boolean createdlocally) {

chat.addMessageListener(new MessageListener() {


public void processMessage(Chat chat, Message Message) {

// Process your message here





now add this class as a chatListner to your xmpp connection

ChatManager chatManager = new ChatManager();


You could also try below code

ChatManager chat = connection.getChatManager();

chat.createChat(jid, new MessageListener() {


public void processMessage(Chat chat, org.jivesoftware.smack.packet.Message arg1) {



Hope this will work

1 Like

Thanks for your response.

I have missed MessageListener in chatCreated(Chat chat, boolean createdlocally) method.

Your resolution works well, thanks again.

1 Like

Thanks a lot…!