RTC Forums
April 28, 2024, 11:39:55 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: TRtcDataClientLink failover to multiple TRtcHttpClient  (Read 4215 times)
zsleo
RTC Expired
*
Posts: 80


« on: June 09, 2011, 03:21:51 PM »

I have an existing RTC application that I want to extend communicate with multiple redundant servers.

The approach I have taken is to have my TRtcClientModules connected to a single TRtcDataClientLink.

In turn I connect the TRtcDataClientLink to one of four TRtcHttpClients. All works fine until I take the server to which the TRtcHTTPCllient is connected.

When I bring the server back on line the TRtcHttpClient does not reconnect to the server unless I restart the TRtcHttpClient app.

If I connect the TRtcClientModules straight to the TRtcHttpClient I can take the server up and down as often as I want and it always reconnects.

*** I am using Delphi XE with RTC v4.05 (2010.Q4); the TRtcHttpClient(s) are set to AutoConnet = true and Blocking = True

Also, once I get this working I want to switch the TRtcDataClientLink between 4 different TRtcHttpClients depending on which server the is alive. *** Is this the correct approach or is there a better way to do it?

TIA

Zane

Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: June 09, 2011, 06:40:21 PM »

These components simply aren't designed to be used the way you want to. If you want to be able to switch between Servers, you should do so by changing the properties of the TRtcHttpClient component or use TRtcDualDataClientLink components and then decide per request which TRtcHttpClient component should be used. Changing component links when they are "live" is a no-go.

Best Regards,
Danijel Tkalcec
Logged
zsleo
RTC Expired
*
Posts: 80


« Reply #2 on: June 09, 2011, 11:07:55 PM »

Danijel

Will it work if I cascade 3 TRtcDualDataClientLinks (i.e. Modules connect to DualLink1 and DualLink1 connecting to DuaLink2 and DuaLink3).

The management of this method seems overly complicated.

Overnight I started experimenting with runtime create the TRtcDataClientLink; if the connected server goes down I destroy the TRtcDataClientLink and recreate a TRtcDataClientLink connecting it to the next server until one server connects. Not tested fully yet but it is working better than other methods I have tried.

My first attempt was to change the properties of the TRtcHttpClient but when a proxy server was used I was getting too many false positive connections when changing between server.

Regards

Zane
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: June 09, 2011, 11:35:32 PM »

Regardless of how you do it, the "OnConnect" event is not a reliable way to check if a Server is alive. Even if you are not going through a Proxy, being able to open a connection to a Server does not guarantee that it is YOUR Server. You need to send a request and wait for a response to see if the Server is alive and ready. What you are calling "false positives" are probably OnConnect events which you get from the RTC SDK once the WinHTTP/WinInet API returns a positive result after creating a connection object, but there is no way for you or the RTC SDK to know if the request will go through - unless a request is really sent.

In other words ... I think you should simply use a single TRtcHttpClient component, try sending a request out to see if the Server is available and responds correctly, then switch to a different Server by changing TRtcHttpClient properties after your request aborts.

An alternative to changing TRtcHttpClient properties would be to use several TRtcDualDataClientLink components or to write your own TRtcMultiDataClientLink component which would work for more than 2 TRtcHttpClient components. I am sure you should be able to implement a TRtcMultiDataClientLink if you take a closer look at the TRtcDualDataClientLink component, which is simply an extension of the TRtcDataClientLink component and could be extended using very smilar code to work with one or two more connection components.

Your idea to create and destroy a TRtcDataClientLink component might work in some cases, but since the components were NOT designed to work this way, chances are that you will get yourself into a situation where things will stop working and you won't know why. Especially if you are using the components in multi-threaded or asynchronous mode, destroying a component could result in AVs at some later point.

Best Regards,
Danijel Tkalcec
Logged
zsleo
RTC Expired
*
Posts: 80


« Reply #4 on: June 10, 2011, 12:03:56 AM »

Thanks,

I will look at the TRtcDualDataClientLink / TRtcMultiDataClientLink solution.

BTW the false positives are not from any of the RTC components. When I change the TRtcHttpClient setting and trigger a reconnect to server, no connection request is received by the server. I have a "is the client app permissioned" function that (I feel) is being cached somewhere. As part of this extension I am including session id in the process. With this implemented most times it takes about 4 attempts to get permissioned and sometimes up to 8 attempts.

Regards

Zane
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.024 seconds with 16 queries.