I want close idle connection on TIdHttpServer.
Here https://stackoverflow.com/a/35107685/2936170 i found
[...] the ReadTimeout property can be used to disconnect slow/dead clients that do > not send requests in a timely manner.
On TIdHttpServer server i have set the ReadTimeout to 1 second on OnConnect event
begin
IdHTTPServer.KeepAlive := False;
IdHTTPServer.OnConnect := OnConnect;
IdHTTPServer.DefaultPort := 80;
IdHTTPServer.AutoStartSession := False;
IdHTTPServer.SessionState := False;
IdHTTPServer.Active := True;
end;
procedure OnConnect(AContext: TIdContext);
begin
AContext.Connection.Socket.ReadTimeout := 1000; // 1 second
end;
For test the server timeout, i have created a simple client and i make a TCP connection with TIdTCPClient
begin
IdTCPClient.Port := 80;
IdTCPClient.Host := '127.0.01';
IdTCPClient.Connect;
end;
On windows network activity section, from resource monitor, i see in the tpc connection list the client and the server connection. Each connections (server and client) persists over the server timeout...
Why IdHttpServer don't close the connection over the readtimeout?
UPDATE 1
tcp connection disappear after 2 minutes (but my timeout is 1 second).
UPDATE 2
if i comment out the line of readtimeout, the connection never disappear. IdHTTPServer seem to have a defaut infinite timeout. I think readtimeout work, but windows network activity is not a real time status info.