Messages Dropped in packListerner

Dear All Experts,

I am writing this jabber bot that is supposed to be logged on all the time, and do something when it receives messages. Everything works fine in normal cases. So I try to test the exteme case, by writing another bot, logged into another account. and use a ‘‘for’’ loop to send about 1000 messages in a row to the jabber bot, to see if the jabber bot can received all of the messages.

some of the messages got dropped. the messages got dropped are not some random messages, but messages that come later. So I am guessing there’'s a buffer in the receiveListener.

I have attached the simple version of my jabber bot below.

PS : The number of messages increase SLIGHTLY when i decrease the sleep time.


import org.jivesoftware.smack.*;

import org.jivesoftware.smack.packet.*;

import org.jivesoftware.smack.filter.*;

import java.util.*;

import java.sql.*;

public class JabberBotTest extends Thread {

//JID of the php bot

private final static String PHP_BOT_JID="php@xxx.com";

private Connection dbConn;

private XMPPConnection jabberConn;

public int count = 0 ;

//debug flag

protected static boolean DEBUG=true;

/**

  • Constructor

  • Job : - connect to jabber, sql, and then update all of the status for ppl in the roster list

**/

public JabberBotTest() throws Exception{

this.jabberConn = new XMPPConnection(“xxx.com”);

this.jabberConn.login(???, ???);

}

public void createListeners ()

{

try{

final Chat phpbotChat = this.jabberConn.createChat(PHP_BOT_JID);

PacketListener packetListener = new PacketListener() {

public void processPacket(Packet packet) {

final Message message = (Message) packet;

count++;

System.out.println(count*" Message received from “*message.getFrom()+” : " + message.getBody());

}

};

jabberConn.addPacketListener(packetListener, new PacketTypeFilter(Message.class));

}catch(Exception ex){ex.printStackTrace();}

}

public static void main(String args[]){

JabberBotTest bot=null;

try{

bot = new JabberBotTest();

}catch(Exception ex){

ex.printStackTrace();

}

bot.createListeners();

try{

//bot.join();

while(true) {

sleep(500);

}

}

catch (InterruptedException ex){

ex.printStackTrace();

System.out.println(“Now turning off bot”);

}

}

}

Message was edited by:

Hans Paul

OH. Interesting discovery. The 1000 messages I send from the other bot is labeled 1-1000 in the message. Then I look the the messages recevied in the jabberBot, it’‘s not really in order…it’'s more like

5

4

3

2

1

11

10

9

8…

etc.

Hey Hans,

Which XMPP server are you using? By default Smack has a limit of packets to accumulate (per PacketCollector) which is 65536. Since you are sending just 1000 messages you shouldn’'t be hitting that limit.

I’'d recommend opening the window debugger and check 1) the order in which the messages are being received by Smack and 2) check if Smack is receiving all the messages from the server.

Regards,

– Gato

I am running jabberd

Hey Paul,

Did you have an opportunity for checking the recommendations I gave you in my previous post? I guess that the server is choking or something. The best way to find out what is going on is to check with the debugger.

Thanks,

– Gato

yea I did look at the debugging info.

The debugging info shows smack did receive the packets. So it looks like jabberd got choked. If you know something about jabberd, do u know how to configure it to increase the buffer size or something?

I’'m no expert in jabberd. You can either try posting in their forums or better yet…use Jive Messenger.

Regards,

– Gato