powered by Jive Software

Simple code example does not work with Smack 3.4.1, but does with 3.2.1

Hi there

I installed Openfire 3.9.1 with Smack 3.4.1 (standard installaion of Openfire with in memory database).

The basic example does not work with Smack 3.4.1, but does with 3.2.1. I can send messages with both versions, but the MessageListener is not called with 3.4.1. The example I run:

Connection connection = new XMPPConnection(“jabber.org”);

connection.connect();

connection.login(“mtucker”, “password”);

Chat chat = connection.getChatManager().createChat("jsmith@jivesoftware.com", new MessageListener() {

public void processMessage(Chat chat, Message message) {

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

}

});

chat.sendMessage(“Howdy!”);

Thanks,

Adrian

Did you really run that example? With the same credentials used?

But anyway, with the provided information I can only suggest that you try to debug the cause.

HI Flow

Thanks for getting back to me.

Did you really run that example? With the same credentials used?

Yes, the only thing I change is the version in my Maven pom file.

Adrian

Adrian Zylinder wrote:

Did you really run that example? With the same credentials used?

Yes, the only thing I change is the version in my Maven pom file.

I wonder how that worked, given that there is likely no mtucker@jabber.org with ‘password’ as password.

Hi, sure I changed the credentials for my test (I just copy pasted the example straight from the docs):

----- …

connection.login(“jose”, “gogogo”);

Chat chat = connection.

getChatManager().createChat(“adrian@haf”, new MessageListener() {

----- …

I just cloned the git project and found the point in time where it stopped working for me:

5bbf6cf22471a6f6c767881395ffdc1e583a9b61 broken

(Added some configuration to the ChatManager to allow for different matching modes on incoming messages with no thread id.)

782448b3ec668c4b10d4d1626d05d7beb4924793 works

With the commit 5bbf6cf the following code was removed from the ChatManager which causes the example to fail:


if (chat == null) {

// Try to locate the chat based on the sender of the message

chat = getUserChat(message.getFrom());

}


I’m using the latest Spark client to respond to the example java chat sender. I’m not the expert, but maybe the Spark client is not returning the threadId back to Smack in the same field, or not at all?

Thanks,

Adrian