Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
kostrin #1
Member since May 2013 · 9 posts
Group memberships: Members
Show profile · Link to this post
Subject: Send Message - SSL error and session close
So I'm trying to send a basic message from one online user to another online user. But i'm getting an error because I have not closed the connection but I am closing the connection.
Here is my code:

        public void sendMessage(string receiver, string message)
        {
            client.OnMessage += new EventHandler<MessageEventArgs>(xmppClient_OnMessage);
            var msg = new Message
             {
                 To = new Jid(receiver,false),
                 From = _jid,
                 Type = MessageType.chat,
                 Body = message
             };
            client.Send(msg);
            Logger.log("MessageSent!");
            client.Close();
        }

        private static void xmppClient_OnMessage(object sender, MessageEventArgs e)
        {
            Logger.log("OnMessage!");
            if (e.Message.Body != null)
            {
                Logger.log("{"+e.Message.From.User+"}: "+ e.Message.Body);
            }
        }

Note: this line of code is called for both users at login:
 client.MessageFilter.Add(_jid, new BareJidComparer(),
       new EventHandler<MessageEventArgs>(xmppClient_OnMessage), null);

Errorlog:

javax.net.ssl.SSLException: Inbound closed before receiving peer's close_notify: possible truncation attack?
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.fatal(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.fatal(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.closeInbound(Unknown Source)
at org.apache.mina.filter.support.SSLHandler.destroy(SSLHandler.java:167)
at org.apache.mina.filter.SSLFilter.sessionClosed(SSLFilter.java:367)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextSessionClosed(AbstractIoFilterChain.java:269)
at org.apache.mina.common.support.AbstractIoFilterChain.access$800(AbstractIoFilterChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.sessionClosed(AbstractIoFilterChain.java:633)
at org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.sessionClosed(AbstractIoFilterChain.java:484)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextSessionClosed(AbstractIoFilterChain.java:269)
at org.apache.mina.common.support.AbstractIoFilterChain.fireSessionClosed(AbstractIoFilterChain.java:264)
at org.apache.mina.common.support.IoServiceListenerSupport.fireSessionDestroyed(IoServiceListenerSupport.java:224)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.doRemove(SocketIoProcessor.java:188)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$600(SocketIoProcessor.java:45)
at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:489)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Thanks for the help!
This post was edited on 2013-05-17, 01:08 by kostrin.
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You should not close the connection after sending a message.
The OnLogin event is also to early, try to wait until you get the OnRosterEnd event.

Alex
Avatar
kostrin #3
Member since May 2013 · 9 posts
Group memberships: Members
Show profile · Link to this post
Cool. It worked. Thanks for the help!
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