how to set max retry time of reconnection

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
junchen
Full Member
Full Member
Posts: 9
Joined: 12 Mar 2014, 05:21

how to set max retry time of reconnection

Post by junchen »

hi

how to set max retry time of reconnection when client lost connection to server?
in my test scenario, my client has connected to a server firstly, then close the server, the client try to reconnect the server always, it couldn't transfer to the status of server shut down or server disconnected.

another question, if the AlternativeEndpointUrls has been set, after client lost connection to main server, Can the client connect to alternative end point automatically?

thanks

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: how to set max retry time of reconnection

Post by Support Team »

Hello,

The max retry time is controlled by the ReconnectDelay parameter in the ClientSettings. The default and minimum value is 10000ms.

The AlternativeEndpointUrls are used whenever a reconnect attempt occurs, however, the selection could be overridden by UpdateEndpoint callback.

Best regards
Support Team

junchen
Full Member
Full Member
Posts: 9
Joined: 12 Mar 2014, 05:21

Re: how to set max retry time of reconnection

Post by junchen »

hi

I mean the client try to reconnect the server always after losing connection, it couldn't transfer to the status of server shut down or server disconnected. I think that reconnect delay is the interval between reconnection.

my connection code is like

Code: Select all

           m_Session = new Session(m_Application);
                    m_Session.UseDnsNameAndPortFromDiscoveryUrl = true;
                    m_Session.AlternativeEndpointUrls = new List<string>();
                    m_Session.AlternativeEndpointUrls.Add(AlternativeUrl);
                    m_Session.AutomaticReconnect = true;
                   
                    

                    // Attach to events
                    m_Session.SessionValidationError += new SessionValidationEventHandler(Session_SessionValidationError);
                    m_Session.ConnectionStatusUpdate += new ServerConnectionStatusUpdateEventHandler(Session_ServerConnectionStatusUpdate);
                    m_Session.UpdateEndpoint += new UpdateEndpointEventHandler(Session_UpdateEndpoint);

                     m_Session.Connect(endpointDescription, m_Session.DefaultRequestSettings);

The AlternativeEndpointUrls are never used whenever a reconnect attempt occurs

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: how to set max retry time of reconnection

Post by Support Team »

Hello,

the AlternativeEndpointUrls are used for connecting if the inital connect fails and retryInitialConnect is set to RetryInitialConnet.Yes. Once a connection could be created, only the Endpoint that worked is used for reconnecting. In other words: the alternative is only tried in case the initial failed. However in your case the initial has worked once, and by this the SDK will always try to reconnect to that one.

Best Regards
Support Team

junchen
Full Member
Full Member
Posts: 9
Joined: 12 Mar 2014, 05:21

Re: how to set max retry time of reconnection

Post by junchen »

hi
after I have changed the connection code to

Code: Select all

m_Session.Connect(endpointDescription, RetryInitialConnect.Yes, m_Session.DefaultRequestSettings);
then start main server and alternative server, close the main server, client do the initial connection, but the client always try to connect the main server, it does not transfer to alternative server.

Post Reply