powered by Jive Software

Slow package delivery

Dear All,

I’m implementing a Java-based RPC service over XMPP. I’m using ejabberd and smack as an xmpp client.

When i’m sending 100 simple XMPP messages to a recipient (takes only seconds), the other entity receives it very slowly (takes minutes).

The recipient entity has only a packetlistener and printing the delivery timestamp.

I edited the source code of smack to print the packet listener call’s date and the code was invoked very slowly.

Whet could be the problem? Is there a timing problem/configuration in ejabberd or the smack library contains a scheduling?

Any help is much appreciated.

Thanks in advance!

Here is a code sample demonstrating my problem:

public class XMPPSimpleTest {     private static CountDownLatch latch;     public static void main(String[] args) throws Exception {         int messageCount = 1000;
        long time = 0;
        latch = new CountDownLatch( messageCount );
          String domain = "prototype";         ConnectionConfiguration config1 =
                new ConnectionConfiguration(
                        "localhost", 5222, domain
                  );
        config1.setCompressionEnabled( true );
        config1.setReconnectionAllowed( true );         XMPPConnection conn1 = new XMPPConnection( config1 );
        conn1.connect();
        conn1.login( "test1", "test1" );         ConnectionConfiguration config2 =
                new ConnectionConfiguration(
                        "localhost", 5222, domain
                  );
        config2.setCompressionEnabled( true );
        config2.setReconnectionAllowed( true );         XMPPConnection conn2 = new XMPPConnection( config2 );
        conn2.connect();
        conn2.login( "test2", "test2" );         Chat c = conn1.getChatManager().createChat( "test2@"+domain, new MessageListener(){
            @Override
            public void processMessage(Chat chat, Message message) {
            }
        } );         System.out.println(" " + (time = System.currentTimeMillis()) );
        for( int i=0; i<messageCount; ++i )
            c.sendMessage("Domo");
                conn2.addPacketListener(
            new PacketListener(){
                @Override
                public void processPacket(Packet packet) {
                    System.out.println(packet + " " + latch.getCount() );
                    latch.countDown();
                }
            },
            new PacketTypeFilter( Message.class )
        );         latch.await();         System.out.println(" " + (System.currentTimeMillis()-time) );         conn1.disconnect(); conn2.disconnect();
    } }

If you run it, you will see, that only 3-4 messages arrives in a second. Any idea?

Hi,

ejabberd limits the bandwidth for every user connected. If you send 1000 messages within some seconds you exceed the bandwidth limit.

The limit can be configured in the ejabberd configuration file (normally located at /etc/ejabberd/ejabberd.cfg)

%%%   ===============
%%%   TRAFFIC SHAPERS %%
%% The "normal" shaper limits traffic speed to 1.000 B/s
%%
{shaper, normal, {maxrate, 1000}}.

If you have access to the ejabberd configuration just increase that value. (Default is 1000, admins have 50000)

Best regards,

Henning

Thank you a lot! I really appreciate it, could not image what was the problem!

I will try this immediately

.

It works! Thanks again. Sorry for posting this problem here …