0

I have problem with setting Callback Server in Delphi Tokyo. I've setup a Datasnap WebBroker Server, then i use

FDSCallBackClientManager.RegisterCallback(sCallbackID,FDSCallBack);

on my client to connect callback server, it can connect and i can send a broadcast message to other client, but after a few minutes since connected, it will disconnected, when i try to broadcast message it will raise an exception telling that the communication is timeout.

I'm using HTTP protocol for the connection, this is not happening when using TCP/IP protocol. The code is just the wizard to create webbroker application targeting Apache. Here the code for the SQLConnection :

FConnection.Params.Values['CommunicationIPVersion'] := 'IP_IPv4';
  FConnection.Params.Values['Hostname'] :=
    TCSClass_Configuration.ReadConfig(
      ClientVariables.Config.FileName,
      AProfile,
      'Hostname',
      'localhost'
    );
  FConnection.Params.Values['Port'] :=
    TCSClass_Configuration.ReadConfig(
      ClientVariables.Config.FileName,
      AProfile,
      'WebPort',
      '80'
    );
  FConnection.Params.Values['DatasnapContext'] :=
    TCSClass_Configuration.ReadConfig(
      ClientVariables.Config.FileName,
      AProfile,
      'DatasnapContext',
      'datasnap'
    );
  FConnection.Params.Values['URLPath'] :=
    TCSClass_Configuration.ReadConfig(
      ClientVariables.Config.FileName,
      AProfile,
      'URLPath',
      'rest'
    );
  FConnection.Params.Values['ConnectTimeout'] :=
    TCSClass_Configuration.ReadConfig(
      ClientVariables.Config.FileName,
      AProfile,
      'ConnectTimeOut',
      '1000'
    );
  FConnection.Params.Values['CommunicationTimeout'] :=
    TCSClass_Configuration.ReadConfig(
      ClientVariables.Config.FileName,
      AProfile,
      'CommunicationTimeOut',
      '1000'
    );

And here the code to connect to callback server:

FDSCallBackClientManager.ChannelName := FCallbackChannelName;
FDSCallBackClientManager.DSHostname :=
  FConnection.Params.Values['Hostname'];
FDSCallBackClientManager.DSPort :=
  FConnection.Params.Values['Port'];
FDSCallBackClientManager.DSPath :=
  FConnection.Params.Values['URLPath'];
FDSCallBackClientManager.CommunicationProtocol :=
  FConnection.Params.Values['CommunicationProtocol'];
FDSCallBackClientManager.ConnectionTimeout :=
  FConnection.Params.Values['ConnectTimeout'];
FDSCallBackClientManager.CommunicationTimeout :=
  FConnection.Params.Values['CommunicationTimeout'];

sManagerID := TDSTunnelSession.GenerateSessionId;
sCallbackID := TDSTunnelSession.GenerateSessionId;

FDSCallBackClientManager.ManagerId := sManagerID;

if FDSCallBack = nil then
begin
  FDSCallBack := TCSClass_Callback.Create(
    Self,
    sManagerID,
    sCallbackID
  );
end;
FDSCallBackClientManager.RegisterCallback(sCallbackID,FDSCallBack);

So can anyone give me some advice what am i missing?

  • That's the limitation of http - it times out even if you use it in a client-server way. So, you can't setup callbacks using http. Instead you must use tcp/ip - and even with tcp/ip, you will have to setup some keep alive mechanism because that times out too, it just takes much longer than http. – Freddie Bell Jun 13 '18 at 13:12
  • Hi, thanks for the information, i thought the same way, but there is an example of using Callback with Javascript Client that can send text to web client. Here is the link https://www.youtube.com/watch?v=xVUAisxqW0U, it is made by Mat DeLong. So there must be something need to be setup in order to make http callback possible – Iwan Cahyadi Sugeng Jun 14 '18 at 16:20
  • Yes, there is a way to setup callbacks for http (web-based) thin clients. The clients here are not Windows executables, but rather javascript web-pages running in a browser to get portions of a web-page to self-refresh when callbacks are executed. As I'm not a web developer, I haven't tried it. But you may have more success. There's a starting point at (https://mathewdelong.wordpress.com/2011/05/30/heavyweight-callbacks/) – Freddie Bell Jun 14 '18 at 17:34
  • You may have some success using the mechanism you have already tested, if you just implement a keep-alive. To do this, simply broadcast a predefined short message on the channel at a regular intervals. For http, you might try every 30 seconds and see if the callback connection "stays up". – Freddie Bell Jun 14 '18 at 17:40
  • Hi @nolaspeaker, thanks for the tips, i've found the article already, but have not tried it myself, i will give it a try, for the keep alive solution, i've tried it and it is working, but that would make Callback useless since i can directly use the interval to request new information instead of using callback at the first place. I will try the article first. Thanks – Iwan Cahyadi Sugeng Jun 16 '18 at 01:59
  • Of cource, but using a keep alive ensures that messages that are sent at other times, arrive as soon as possible. Datasnap callbacks are also peer-to-peer, not client/server, so how are you going to request messages from another peer at regular intervals!? – Freddie Bell Jun 16 '18 at 05:32

0 Answers0