Message bouncing

Hi all,

I have the following problem: I connect to my google talk account (user1) and I start a chat with a friend (user2).

user1 sends a message to user2 with the following code:

Message message = chat().createMessage();


message.setBody(“my message”);


I have then a registered packet listener like this:

PacketFilter filter = new AndFilter(

new PacketTypeFilter(Message.class), new ToContainsFilter(


messageListener = new PacketListener() {

public void processPacket(Packet packet) {

if (packet instanceof Message) {

processMessage((Message) packet);




connection.addPacketListener(messageListener, filter);

Unfortunately the first message receive by my message listener is a message with the same body as the message I sent, but with the “from” field equal to user2 (and “to” user1). It really looks like useer2 is bouncing back my message. I cannot find anything on this in the forum. I must be doing something wrong.

I would really appreciate some help! I’'m a smack primer and I would really like this to work soon.



hi francesca…

why did you set msg.setfrom() ?

if user1 want to send a message to user2, you have to set msg.setBody(“bla bla bla”) and msg.setTo(“user2”).

or maybe i don’'t understand your problem…



Thanks! This helped a lot! I also discovered another little mistake and now works fine.

Thanks again for the prompt and very helpful answer. As I said I am a smack primer and I now realise how silly my error was.