Hi,
I've setup a Rest Server as apache module, and successfuly connect the server using Rest Client Connection. But i want to add Callback capability. Here is the code
procedure TCSClass_RestClient.PrepareCallback;
var
sUniqueID : string;
sUniqueCallbackID : string;
begin
//Create Callback
sUniqueID := TDSTunnelSession.GenerateSessionId;
sUniqueCallbackID := TDSTunnelSession.GenerateSessionId;
FRestManager := TDSRestClientChannel.Create(
sUniqueID,
FChannelName,
FRestClient);
FRestManager.OnChannelStateChange := Callback_HandleChannelStateChange;
FRestCallback := TDSRestClientCallback.Create(
FRestManager,
sUniqueCallbackID,
function(AValue: TJSONValue; ADataType: string): Boolean
begin
if Assigned(FOnRestClient_ReceiveData) then
begin
FOnRestClient_ReceiveData(AValue, ADataType);
end;
Result := true;
end
);
if FRestManager.Connected then
begin
FRestManager.RegisterCallback(FRestCallback);
end
else
begin
FRestManager.Connect(FRestCallback);
end;
end;
This code is successfuly connect to the Rest Callback Server, but the problem is that the server disconnect after about 1 minute with an error message of "First chance exception at $75129617. Exception class ENetHTTPClientException with message 'Error receiving data: (12002) The operation timed out'. Process OperatorAssistant.exe (2212)", if i use the CallbackStateChange event, it return an EventType of rChannelClosedByServer. I tried to reconnect to callback server by calling the above function every time server disconnect the callback server, but it is always disconnected every 1 minute.
I set DSServerClass.LifeCycle to Invocation, DSServer.ChannelResponseTime as default = 30.000. So what is the problem and what is the configuration i need to set to make the callback server did not forcely close the callback connection other than a network failure
And one more thing, how to property disconnect a callback connection from the client, currently i use this code :
if FRestCallback <> nil then
begin
FRestManager.UnregisterCallback(FRestCallback);
end;
I use Delphi Tokyo 10.2.3
Thanks for helping
Iwan