1

I followed the guide in Delphi Labs: Datasnap XE - Callbacks , Callbacks seems to work good. Yet, leaving the client sides idle for more than a hour -- seems to cause clients callbacks stop working. I changed the server DSTCPServerTransport.KeepAliveEnabled, .KeepAliveInterval, .KeepAliveTime -- but it didn't help in any way.

Does anyone know how can I keep the clients connected overtime?

1: https://edn.embarcadero.com/article/41374

B. Nighthawk
  • 11
  • 1
  • 3

1 Answers1

0

I also use Datasnap callbacks in several applications. My solution was to setup a timer that measures how long it takes for a specific message (eg '*ping') that was sent using BroadCastToChannel to be received by a registered callback on the same channel in the same application. I allow for 5 seconds in a mobile application, and if the echo of my ping isn't received in that time, I assume my callback isn't working anymore. I do what I call "recycle the callback". That is, I de-register the previous callback (causes no errors if it fails) and register a new one (my callback id's are timestamp based so they are all unique). My "ping timer" runs on 1 minute intervals which is often-enough for my application(s). This solution would be a lot of code to present here, so I hope my description will help you find a solution that works for you. Ask questions if you're unsure.

Freddie Bell
  • 2,186
  • 24
  • 43
  • That was my initial intention (of implementing what you described above)... Isn't there a "nicer" way doing that?. If such a service is intended to be scaled isn't such implementation kinda overhead? – B. Nighthawk May 02 '18 at 14:06
  • No. I would say it's essential functionality to provide reliability to your service. In my case, I've found it to be very robust once I implemented my own keep alives in this way. – Freddie Bell May 02 '18 at 15:36
  • Now I am thinking of writing the code you suggested. A question: How did you address the issue if someone miss X amount of messages,. are you keeping all the messages on the server indexed, sending that missed messages again? and then I get back to my question, isn't making the whole process too messy? – B. Nighthawk May 02 '18 at 15:37
  • No, again, it's making your service very reliable. – Freddie Bell May 02 '18 at 15:38
  • @B Nighthawk. The answer your other question. It is near-impossible to intercept the message at the Datasnap server, so instead you might want to create a "proxy server", which is itself a "callback client" to do logging (to database) and forwarding of messages. I can tell you is that it takes a lot of code to make a dependable service. The `DSClientCallBackChannelManager` component is just 1 of many pieces you're going to need. – Freddie Bell May 02 '18 at 16:30