Disconnect channel after inactivity for a given duration

Hello,

I’m using a TROSynapseSuperHTTPChannel to communicate with my server and to avoid saturating it, I Create/Destroy between each “high level” operation, that can be made of multiple calls to the server.
I know this is not ideal because there is a delay in establishing the connection, or even more frequently, in closing it. I have noticed it spends quite some time in the SetInactive method when freeing the channel.

To avoid this, I would like to create a system that would be a bit more intelligent, by keeping the connection open for a given duration after the last transfer occurred on the channel.
In regular HTTP, this is the keep-alive option but I could not find anything along those lines in the channel itself.

I thus went looking at the server where I use a TROIpSuperHTTPServer and I see that it sets the KeepAlive property of its fSocket to True.

I saw the IdleTimeout property on TIPAsyncHTTPServer but I’m not sure this is what I’m looking for nor how I could access it from my TROIpSuperHTTPServer instance.

Thus, is the KeepAlive property what I’m looking for? And if yes, is there a way to set the associated timeout?

Regards,
Olivier

you are right: KeepAlive is set to True on server-side:

constructor TROIpSuperHTTPServer.Create(aOwner: TComponent);
..
  fSocket.KeepAlive := True;

and on client-side:

constructor TROSynapseSuperHTTPChannel.Create(aOwner: TComponent);
  function _CreateHTTPSend: THTTPSend;
..
    Result.KeepAlive := True;

IdleTimeout is set to 3 minutes by default.
access to TIPAsyncHTTPServer instance you can get via TROIpSuperHTTPServer.OnManualBindSocket event.
note: in this event you need to manually bind port like:

TIPAsyncHTTPServer(Sender).Socket4.Bind('0.0.0.0', TIPAsyncHTTPServer(Sender).Port);
// or
TIPAsyncHTTPServer(Sender).Socket6.Bind('::', TIPAsyncHTTPServer(Sender).Port);
..
x := TIPAsyncHTTPServer(Sender).IdleTimeout;

Thanks for this, but it would more convenient if a property surfaced the KeepAlive and IdleTimeout values used internally