Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
fx #1
Member since Nov 2011 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: Reconnect don't work
I'm developping a Silverlight Client using MatriX but I have issue when trying to implement a reconnect method.

I catch SocketException on send method but when calling Open method nothing happens.

In short the code is :
public override void Send(Matrix.Xml.XmppXElement el)
        {
            try
            {
                base.Send(el);
            }
            catch (System.Net.Sockets.SocketException)
            {
                Close();
                //Wait 30s
                Open();
            }           
        }

I have try to create a new client but I get the same issue.

PS : I use Socket connection
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you should not catch this exceptions in your code.
MatriX raises OnClose and OnError events when the connection was closed either by the server or network errors.
When you get an OnClose then you should not reconnect directly in this event because
A) MatriX is asynchronous and still does some cleanup
B) When you have network errors then a reconnect will fail in most cases until your network is back

So when you get these event start a timer and try to reconnect after eg. 5 seconds. When this fails again try to reconnect again after 10 seconds, and so on. When you reconnect immediately and the network is down then you are hanging in a loop which makes no sense.

Alex
Avatar
fx #3
Member since Nov 2011 · 6 posts
Group memberships: Members
Show profile · Link to this post
First, I will add that I wait 30 seconds before try to reconnect.

I have make some changes without success.
1) I remove the try catch but , OnError is not fired. So the application block on a not handled SocketException.

2) I have no log after connection lost (throught OnSendXml)

3) I used a remote server  to test

The server is also developed by me.
I think it's blocking on Socket side because the socket is set as "disconnected" at server side. I don't know what happens in MatriX .

Can you help me to try something ?
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
First make sure that you are using the latest binary from here:
http://www.ag-software.net/download-directory/

Whenever MatriX gets a socket disconnect it closes the Xmpp connection and raises an OnClose.
After you have received an OnClose you should not call Send before you are properly reconnected to the server.

When you try to send data without a socket MatriX should raise an error.

Alex
Avatar
fx #5
Member since Nov 2011 · 6 posts
Group memberships: Members
Show profile · Link to this post
I have updated the binary before send you a post. So I am on 1.4.4.4 (for server and for sl).

Now I launch reconnection on onClose event. This "bind" works well but the reconnection not.

I have used Wireshark to trace tcp packet on port 4502 and nothing appends when we try to reconnect.

This is very strange, the Open method should recreate a socket no ?
Avatar
Alex #6
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by fx:
This is very strange, the Open method should recreate a socket no ?

yes it should. Have you tried to start a timer in the OnClose event as I suggested?
Avatar
fx #7
Member since Nov 2011 · 6 posts
Group memberships: Members
Show profile · Link to this post
Yes in fact, I open a childwindow witch have a DispatcherTimer. So we wait 30s and next we call the open method.
(connection object is shared via a static property)
Avatar
fx #8
Member since Nov 2011 · 6 posts
Group memberships: Members
Show profile · Link to this post
No ideas where the problem could from ?

I'm testing different sdk for a business project, your seems to be very good but this can be clearly blocking.
Avatar
Alex #9
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
no sorry, I have no idea. It works fine for me, and we had no such error reports yet from customers.
Do you get any error events on the reconnect attempt?

If you don't get it working it would help when you upload a basic test project which helps us to cause the problem.

Alex
Avatar
fx #10
Member since Nov 2011 · 6 posts
Group memberships: Members
Show profile · Link to this post
Ok I will go back to you
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: MatriX RSS