Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
hexin #1
User title: to search knowledge
Member since Mar 2007 · 34 posts · Location: China
Group memberships: Members
Show profile · Link to this post
Subject: why sending long message leaded to disconnect from server
 when Miniclient send message, especially long message, the client always automatically disconnects from server, and soon automatically reconnect to server.The server i use is openfire 3.4.5. When i use spark, this problem doesn's happen. Is anyone know why?
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
are you sure the xml of your long message is valid?
When agsXMPP disconnects there must be a error message.
Can you check all error events of XmppClientConnection?
How long is your message?

Alex
Avatar
jbriguet #3
Member since Mar 2008 · 4 posts
Group memberships: Members
Show profile · Link to this post
This seems to be an error with openfire, the bug should be corrected in the 3.5.0 RC1 available.
Avatar
hexin #4
User title: to search knowledge
Member since Mar 2007 · 34 posts · Location: China
Group memberships: Members
Show profile · Link to this post
I have try with  openfire 3.5.0 RC1,but the problem still exists. And i said the spark doesn't have this problem.
Avatar
hexin #5
User title: to search knowledge
Member since Mar 2007 · 34 posts · Location: China
Group memberships: Members
Show profile · Link to this post
 When i send long message,I trace the send function in ClientSocket class.

public override void Send(byte[] bData)
        {
            lock (this)
            {
                try
                {
                    base.FireOnSend(bData, bData.Length);
                    if (m_Compressed)
                    {
                        byte[] tmpData = new byte[bData.Length];
                        bData.CopyTo(tmpData, 0);

                        bData = Compress(bData);                       
                    }

                    // .NET 2.0 SSL Stream issues when sending multiple async packets
                    // http://forums.microsoft.com/MSDN/ShowPost.a…?PostID=1242…
                    if (m_PendingSend)
                    {
                        m_SendQueue.Enqueue(bData);                       
                    }
                    else
                    {
                        m_PendingSend = true;                       
                        try
                        {
                            m_NetworkStream.BeginWrite(bData, 0, bData.Length, new AsyncCallback(EndSend), null);
                        }
                        catch
                        {
                            Disconnect();
                        }
                    }
                }
                catch (SocketException ex)
                {
                    throw ex;
                }
            }
        }

After executing the the following statement in above function:
  m_NetworkStream.BeginWrite(bData, 0, bData.Length, new AsyncCallback(EndSend), null);

The program immediately jumped to the following function:
private void EndReceive(IAsyncResult ar)
        {
            try
            {
                int nBytes;
                nBytes = m_NetworkStream.EndRead(ar);
                if( nBytes > 0 )
                {
                    // uncompress Data if we are on a compressed socket
                    if (m_Compressed)
                    {                       
                        byte[] buf = Decompress(m_ReadBuffer, nBytes);
                        base.FireOnReceive(buf, buf.Length);
                        // for compression debug statistics
                        //base.FireOnInComingCompressionDebug(this, m_ReadBuffer, nBytes, buf, buf.Length);
                    }
                    else
                    {
                        //Console.WriteLine("Socket OnReceive: " + System.Text.Encoding.UTF8.GetString(m_ReadBuffer, 0, nBytes));                       
                        // Raise the receive event
                        base.FireOnReceive(m_ReadBuffer, nBytes);
                    }
                    // Setup next Receive Callback
                    if (this.Connected)
                        this.Receive();
                }
                else
                {
                    Disconnect();
                }
            }
            catch(ObjectDisposedException)
            {
                //object already disposed, just exit
                return;
            }
            catch (System.IO.IOException ex)
            {
                Console.WriteLine("\nSocket Exception: " + ex.Message);
                Disconnect();
            }
        }

And in above function,after executing the  following statement:
    nBytes = m_NetworkStream.EndRead(ar);
the value of  nBytes is 0,and so trigger the onclose event.


And I would say, the disconnet event not happen every time, it often happen when i send first long message after I login in.
Avatar
Jabberer #6
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
When EndRead() returns 0 like it does in your case then the socket was closed.
You said that you debug the agsXMPP code, so if there was no exception then the server disconnects you.

Reason for this can be:
  • you send too long stanzas. Most servers have a max stanza limit. Otherwise yo could overflow every xmpp server with long stanzas
  • You send too much data too fast. Most XMPP server have a setting which is normally called karma. This limits the bandwidth of a single user.
  • You send invalid Xml over the wire.
  • server bug

It would be nice if the server closes the stream properly for case 1-3 and not disconnect you without closing the stream and any error message.
Also check your Openfire logs for errors and ask for help in the Openfire community at ignite realtime
Software Developer
AG-Software
This post was edited on 2008-03-28, 07:16 by Jabberer.
Avatar
hexin #7
User title: to search knowledge
Member since Mar 2007 · 34 posts · Location: China
Group memberships: Members
Show profile · Link to this post
I get the following information in the openfire warn.log,

2008.03.20 09:46:00 Closing session due to exception: (SOCKET, R: /127.0.0.1:1371, L: /127.0.0.1:5222, S: 0.0.0.0/0.0.0.0:5222)
org.apache.mina.filter.codec.ProtocolDecoderException: java.lang.ArrayIndexOutOfBoundsException (Hexdump: empty)
    at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:165)
    at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
    at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
    at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
    at org.apache.mina.filter.CompressionFilter.messageReceived(CompressionFilter.java:161)
    at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
    at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
    at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
    at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:239)
    at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:283)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException


Is anyone  know what may lead to this? Is the message i send too long? But When I send the same message at second time.The phenomena I described above didn't happen again.
Avatar
Alex #8
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Try another server with the same message. When there are no problems on other servers then file a bug report in the Openfire forums.

Alex
Avatar
hexin #9
User title: to search knowledge
Member since Mar 2007 · 34 posts · Location: China
Group memberships: Members
Show profile · Link to this post
I test the client again and found that if I set XmppClientConnection's Property  UseCompression as true,the disconneting phenomena happens. If I set  UseCompression as false, the phenomena  doesn't happen.
Avatar
Jabberer #10
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
hexin,

as Alex said before this must be a bug in Openfire. You also did not post any useful information yet in this thread. Please do so, otherwise we cannot help you and will close this thread. And if its an Openfire bug we cannot help you at all.

  • what is a especially long message (size)? Attach the complete xml when possible.
  • Did you try another server software which supports compression? ejabberd, soapbox...?
Software Developer
AG-Software
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS