I just noticed I can't attach a file through the mailing list (makes
sense), so I've put the zip file with HTTPPoster sources online:
http://www.xs4all.nl/~bosma/HTTPPoster.zip
regards,
Merijn
On 03/09/2014 23:34, Merijn Bosma wrote:
Hi all,
For a current project I need to build an HTTP server to which data can
be POSTed, so I build one using OverbyteIcsWebServ.dpr as an example.
I ran into stability problems, and starting slimming my code down to
isolate the problem. I'm now at a point where it seems to be an issue
in ICS code,
though I haven't found the cause yet. Currently the issue is
reproducible using the OverbyteIcsWebServ.dpr which comes with the ICS
code as a demo.
The issue is as follows:
when posting a file to the OverbyteIcsWebServ, sometimes the post
fails, on the client side this manifests as getting back a 408, on the
server
side it manifests as not receiving data at all, or missing the last
block (in case the data is split up in blocks). Looking at
OverbyteIcsWebServ.dpr,
this means HttpServer1PostDocument() is called always and
HttpServer1PostedData() is not called at all, or not for the last
expected block.
If you add the following line:
Display(Format('received %d bytes, total received %d, total expecting
%d', [Len, ClientCnx.FDataLen, ClientCnx.RequestContentLength]));
In procedure TWebServForm.HttpServer1PostedData() in
OverbyteIcsWebServ1.pas, right after Inc(ClientCnx.FDataLen, Len);
So it looks like this:
Len := ClientCnx.Receive(ClientCnx.FPostedRawData +
ClientCnx.FDataLen, Remains);
{ Sometimes, winsock doesn't wants to givve any data... }
if Len <= 0 then
Exit;
{ Add received length to our count }
Inc(ClientCnx.FDataLen, Len);
Display(Format('received %d bytes, total received %d, total
expecting %d', [Len, ClientCnx.FDataLen,
ClientCnx.RequestContentLength]));
{ Check maximum length }
if ClientCnx.FDataLen > MAX_UPLOAD_SIZE then begin
When the fault situation happens, you will see log like:
received 255 bytes, total received 255, total expecting 1420
received 255 bytes, total received 512, total expecting 1420
received 255 bytes, total received 768, total expecting 1420
received 255 bytes, total received 1024, total expecting 1420
received 255 bytes, total received 1280, total expecting 1420
Then it stops (as if the last block was never received), and timeout
(error 408) occurs. Looking with wireshark shows that the last packet
was on the wire, just not received in the application.
To reproduce I've attached a small app which can be tested against
OverbyteIcsWebServ.dpr.This application will show all files found in
subdir 'postdata', you can double click one to post it to given URL.
Sometimes it takes a long time to reproduce, sometimes it happens fast
(first file you post). The 'machine gun' button in the app will post
random files from the postdata subdir fast, to help reproduce.
So, exact steps to reproduce are:
- compile
OverbyteIcsV8Gold.zip\Samples\Delphi\WebDemos\OverbyteIcsWebServ.dpr
and run it
- unzip HTTPPoster with the postdata subdir and run it
- change the IP in HTTPPoster if required
- hit the 'machine gun' button
Log in HTTPPoster will show when the timeout occured (and the 'machine
gun' will be shut off automatically).
I'll try to dig into ICS code later, but first looks give me the idea
that won't be really easy to debug, so I'm hoping for some help from
the guru's
thanks in advance,
Merijn
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be