You are not logged in.
Hi Arnaud,
A second THttpServer finding from the same AirMonitoring install (socket server, STATICFILE_CONTENT_TYPE, 2.4.17809).
The first one - the empty 206 on the first "Range: bytes=N-" of a connection - was meanwhile reported by zen010101 as #767 and fixed in 1aeaa636, thanks!
This one is independent and still present in trunk.
THttpServerSocket.Create calls inherited Create(5000), so every accepted socket has a 5 s SendTimeout, applied per Send() in TCrtSocket.TrySndLow.
A browser <video> stops reading the socket as soon as its forward buffer is full and only resumes when playback has consumed it, which is routinely longer than 5 s (and unbounded while the user pauses).
The socket buffer fills, Send() waits 5 s, nrTimeout, THttpServerSocket.Process sets fKeepAliveClient := false and closes the socket with unsent data, so the browser sees net::ERR_CONNECTION_RESET on the 206 and re-requests from its current offset. Playback "works", but one open tab produced 978 requests / 2.5 GB in 5 hours.
Nothing in the log unless hsoLogVerbose is set.
Repro without a browser: 100 MB STATICFILE, a client reads 2 MB, sleeps 8 s, reads on:
SendTimeout 5000 (default): resumed +852050 bytes > EOF, 2.9 MB of 100 MB received
SendTimeout 60000: resumed +102825984 bytes > full fileOur workaround is OnHeaderParsed: Request.SendTimeout := 10 * 60 * 1000. Since a keep-alive connection already owns its THttpServerResp thread, this does not seem to cost anything, and a vanished peer is still cut by the TCP retransmission timeout.
Would you consider exposing the accepted-socket send timeout on THttpServer (it is not reachable from Create), or raising the default for stream responses? THttpAsyncServer is not affected.
Thanks,
vs.
Offline
The behavior you reported is not necessarily a defect. It is a legitimate timeout policy for a synchronous HTTP server, especially one designed primarily for REST services.
The THttpServer maintains one thread per client, so removing idle connections makes sense.
In fact, your workaround with OnHeaderParsed: Request.SendTimeout := 10 * 60 * 1000 seems similar to nginx
# Video and large-file downloads
location /video/ {
send_timeout 10m;
sendfile on;
root /var/www;
}Did you try with THttpAsyncServer? This server is meant for serving such content, and suffers from no such send timeout AFAIR.
Offline
Thanks - the nginx send_timeout analogy is exactly it.
Retested on trunk 56a182ae and 2.4.17809: THttpAsyncServer is the right server for media - 64 MB STATICFILE through an 8 s client pause, Range byte-exact under 4 parallel keep-alive connections, and the product on it survived 16 seeks and a 5-minute <video> pause in Chrome.
It is in production since last night.
What the first night in production shows is THttpAsyncServerConnection.BeforeProcessRead.
The comment there says the hrsSendBody wait is a loopback-only test race.
On our box it fires in two normal situations:
1. every <video> seek - the browser abandons the open-ended Range response, and behind haproxy the same connection is picked up by 3–4 IOCP reader threads at once, each looping SleepHiRes(5) + a warning for up to 50 ms, 10–40 sllWarning lines per seek
2. our own sync script, which talks to the server over a loopback keep-alive connection and sends two small SOA POSTs back to back - every such pair burns the whole 50 ms budget with 8–11 warning lines, exactly 4 times an hour all night, with no video involved.
Nothing breaks (no exception, no reset, the next request is served), but any keep-alive client that sends its next request right after the previous response pays 50 ms, and the log fills at the wrong level.
Could the wait be done once per connection (or the state flipped when the write completes) and the line go to sllTrace/sllDebug?
Repro: serve any mp4 as STATICFILE from THttpAsyncServer, open it in Chrome, seek - or two keep-alive POSTs in a row on loopback.
And for those who stay on THttpServer (it does serve STATICFILE): would you expose the accepted-socket send timeout as a property or Create parameter instead of the literal 5000 in THttpServerSocket.Create?
The default can stay at 5 s.
Thanks.
Offline