RTC Forums
June 24, 2022, 11:42:32 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Handling losing the server  (Read 48 times)
DPerkins
RTC License
***
Posts: 37


« on: June 13, 2022, 11:43:35 AM »

I'd like to add some resilience to my client application by adding an offline-mode. 

We sometimes have an issue where our RTC server is not available (server crash, internet connection, ransomware etc) and would like our client application to detect this, halt all server requests, and upload collected data once the server is back online.

My plan is to reduce the request timeouts for short/simple requests (so that the user doesn't notice a 30 second timeout pause) and flag as 'offline' if any of these requests fail.  In the background, I would then periodically check for the server's presence and set the offline flag once the server is available again.  This would trigger cached data to be uploaded.

Is there a standard way of detecting server disappearence with minimal delays/timeouts affecting the user?

Many thanks.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1873


« Reply #1 on: June 14, 2022, 02:08:50 AM »

The simplest way for a Client to check if a Server is accessible, would be to send a request to that Server and wait for a response, but you probably know that already.

If your Clients are implemented using the RTC SDK, you can set AutoConnect and ReconnectOn properties to TRUE on your TRtcHttpClient components, then you don't have to manually call Connect when a connection is needed.

For continuous retries in case of a failure, implement the OnRepostCheck event on your TRtcDataRequest component. That event will be triggered if a request failed. Calling TRtcDataClient(Sender).Request.Repost from that event tells the component to try sending the last request to the Server again. Should there be another failure, the same event would be triggered again.

I guess, you already know how to work with these components, but ... if you need an example for using the properties and events I've mentioned here, check the File_Client Project in the Examples/File_Client folder. It doesn't implement exactly what you want, but it shows you how connection errors and request failures can be handled with the RTC SDK.

Best Regards,
Danijel Tkalcec
Logged
DPerkins
RTC License
***
Posts: 37


« Reply #2 on: June 14, 2022, 11:30:03 AM »

Thanks Danijel

I have AutoConnect set to true, but the default for ReconnectOn.  I'll change that.

Any downtime could be significant (hours) so I plan on blocking all comms until I'm sure the connection is established again rather than retrying individual requests.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 16 queries.