Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
johnm60 #1
Member since Jun 2010 · 32 posts
Group memberships: Members
Show profile · Link to this post
Subject: Re-connecting after an unexpected disconnect
Hi Alex

I have been looking into the behaviour of a Matrix application in the context of disconnections from the server. I have looked at these scenarios:

1. The local connection gets temporarily lost
2. The local connection gets lost for a while
3. The server process terminates unexpectedly
4. The server process is shutdown by an admin

In scenario 1, if the connection is only brief then TCP appears to make this transparent -  so OK

In scenario 2, I get an "OnClose" event after some while and once the network connection is re-established I can call Open() and all is well.

scenario 3 looks very much like scenario 2 and there is an OnClose event and once the server is re-started a call to Open() successfully connects.

Scenario 4 seems the one that troubles me. If I ut diagnostics on each error handler, I get the following:

[4652] RECV: <stream:error xmlns:stream="http://etherx.jabber.org/streams">
[4652]   <system-shutdown xmlns="urn:ietf:params:xml:ns:xmpp-streams" />
[4652] </stream:error>
[4652] client_OnStreamError
[4652] SEND: </stream:stream>
[4652] RECV: </stream:stream>
[4652] client_OnClose
[4652] client_OnError System.NullReferenceException: Object reference not set to an instance of an object.
[4652]    at Matrix.Net.ClientSocket.#=qyx35md3FA5opdrc1P7lILQ==(IAsyncResult #=qFF0GzzRCPLpq6DzpsaVVIQ==)

If I then attempt to call Open(), then I get:
[4652] SEND: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="breakdown-service.net" version="1.0" >

But re-connection does not occur. This is the case even if I try to call Close(). The only way I can re-establish a connection is to delete and re-create the XmppClient object and then call Open() against this new object.

Is this expected behaviour and so should I delete and re-create the client object between disconnects to make sure that I will be able to re-connect later when connectivity and the server are working?

Regards
John
Avatar
Alex #2
Member since Feb 2003 · 4328 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by johnm60:
Is this expected behaviour and so should I delete and re-create the client object between disconnects to make sure that I will be able to re-connect later when connectivity and the server are working?

no, you can reuse the XmppClient.
I can't cause your problem. When shutting down my ejabberd test server I get exactly the same log and can reconnect the same XmppClient without problems when the server is restarted. When I try to connect while its down I get an SocketException in the OnError event which is fine as well.

Alex
Avatar
johnm60 #3
Member since Jun 2010 · 32 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex

Against my target server Isode this is consistently reproducible as a behaviour even to a very chopped-down test client. I checked against a copy of OpenFire and this does not cause this behaviour. The only difference I can see is that OpenFire does not send a

[5604] RECV: <stream:error xmlns:stream="http://etherx.jabber.org/streams">
[5604]   <system-shutdown xmlns="urn:ietf:params:xml:ns:xmpp-streams" />
[5604] </stream:error> THREAD 9

Regards
John
Avatar
Alex #4
Member since Feb 2003 · 4328 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
It looks like this is a problem which exists only on MLink servers. I have access to MLink installations, also to Isodes development servers. But I can't shutdown these servers for a test. The problem is either in MLink or MatriX. To find the the problem I have to install a local MLink server which I can shutdown and debug against. I put this on my TODO list because for installing another test server I need some more time.

Alex
Avatar
johnm60 #5
Member since Jun 2010 · 32 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex

I have sent you a PM with the details of my test server, if you want to look closer.

Regards
John
Avatar
Alex #6
Member since Feb 2003 · 4328 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi John,

I installed a new VM with MLink and can reproduce the problem now. MLink does not allow me to close the client stream properly. I get an exception in the middle of the async send operation. I will create a patch for this and upload a new version.
I will post an update here i the thread when is tested and uploaded.

Alex
Avatar
Alex #7
Member since Feb 2003 · 4328 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
uploaded new version 1.3.0.2

Alex
Avatar
johnm60 #8
Member since Jun 2010 · 32 posts
Group memberships: Members
Show profile · Link to this post
Thanks Alex. I have tried it on a couple of workstations and it now reconnects without any issues.

Regards
John
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