Discussion:
Keep-Alive connection timeout/max requests.
(too old to reply)
Arvid Haugen
2008-02-19 14:00:16 UTC
Permalink
I have set "Keep-Alive" in the TidHTTPServer. This keeps the sockets open.

Is there any timeout for this connection, or a max number of requestes that
will be served for each connection?

Or do I need to program this myself? In case I have to implement it myself -
any suggestions how this should be done?

The reason why I am asking is that Apache implements this and I would like
to implement the same behavior. For Apache documentation:
KeepAlive
Syntax: KeepAlive max-requests
Default: KeepAlive 5

This directive enables Keep-Alive support. Set max-requests to the maximum
number of requests you want Apache to entertain per connection. A limit is
imposed to prevent a client from hogging your server resources. Set this to
0 to disable support.

KeepAliveTimeout
Syntax: KeepAliveTimeout seconds
Default: KeepAliveTimeout 15

The number of seconds Apache will wait for a subsequent request before
closing the connection. Once a request has been received, the timeout value
specified by the Timeout directive applies.

One other thing.

I downloaded the latest version of Indy today - 19/2.

In my project with a TidHTTPServer the connections are closed.

I have "Keep-Alive" set to true in the TidHTTPServer, I receive "Keep-Alive"
in ARequestInfo.Connection. But the webserver responds with
"closeconnection" (AResponseInfo.CloseConnection is true). I have tried both
with and without SSL.

Any idea why this happens and what I should do about it? Do I have to set
CloseConnection to false myself?

With the previous version I did not see this. That was the indy version
shipped with Delphi 2006.

/Arvid
Remy Lebeau (TeamB)
2008-02-19 18:57:15 UTC
Permalink
Post by Arvid Haugen
Is there any timeout for this connection
There are two timeouts that are available which you can use to manually
mimic the functionality you are asking for (there is no timeout specific for
it):

1) the connection's ReadTimeout property. If the client does not send a new
request during the specified interval, the connection will timeout and
disconnect. But it will also timeout if the connection is slower than the
interval as well.

2) the server's SessionTimeOut property. If the client does not send a new
request using an existing session during the specified interval, the session
will timeout. You can use the OnCreateSession event to associate a
connection with a session, and then use the OnSessionEnd event to disconnect
the connection.
Post by Arvid Haugen
or a max number of requestes that will be served for each connection?
No.
Post by Arvid Haugen
Or do I need to program this myself?
Yes.


Gambit
Arvid Haugen
2008-02-20 07:04:52 UTC
Permalink
Just a follow up question to make sure I am following you.
Post by Remy Lebeau (TeamB)
1) the connection's ReadTimeout property. If the client does not send a
new request during the specified interval, the connection will timeout and
disconnect. But it will also timeout if the connection is slower than the
interval as well.
Could this be implemented by setting:

AContext.Connection.Socket.ReadTimeout in OnConnect for idHTTPServer?
Post by Remy Lebeau (TeamB)
Post by Arvid Haugen
Is there any timeout for this connection
There are two timeouts that are available which you can use to manually
mimic the functionality you are asking for (there is no timeout specific
1) the connection's ReadTimeout property. If the client does not send a
new request during the specified interval, the connection will timeout and
disconnect. But it will also timeout if the connection is slower than the
interval as well.
2) the server's SessionTimeOut property. If the client does not send a
new request using an existing session during the specified interval, the
session will timeout. You can use the OnCreateSession event to associate
a connection with a session, and then use the OnSessionEnd event to
disconnect the connection.
Post by Arvid Haugen
or a max number of requestes that will be served for each connection?
No.
Post by Arvid Haugen
Or do I need to program this myself?
Yes.
Gambit
Remy Lebeau (TeamB)
2008-02-20 07:11:45 UTC
Permalink
Post by Arvid Haugen
AContext.Connection.Socket.ReadTimeout in OnConnect for idHTTPServer?
Yes.


Gambit

Loading...