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:
If I then attempt to call Open(), then I get:
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
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==)
[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