The concept of fast CGi is that the process outlives the request. This is very usefull for situations where a number of requests are required to complete a larger process.
In this case, I am uploading a larger file (10MB) in chunks. If I tried to do a single POST I would run into the SndTo TIMEOUT:
I am using WinHTTP (not WinInet) which supports 4 timeout settings:
ResolveTO ' resolving a host name
ConnectTO ' establishing a communication socket
SndTo ' Total running time for sending data
ReceiveTO ' Total running time for receiving any data
So by breaking the larger file up into 64k chunks I can send them one at a time. Each chunk is a complete HTTP request and response by the client and is serviced by the FastCGI executable.
But there is a problem. For some reason, the FastCGI executable is terminated after processing each chunk IF the chunk size is larger than about 2500 bytes (determined experimentally)
To test this, I wrote a simple client that issues n WinHTTP POST request's in a row, each with x bytes of POST data. The results are:
-------- 01-05-2009 22:28:17 ---------
1 Bytes sent= 4000
FastCGI Reply: Count= 1, ContentLen= 4000
2 Bytes sent= 4000
FastCGI Reply: Count= 1, ContentLen= 4000
3 Bytes sent= 4000
FastCGI Reply: Count= 1, ContentLen= 4000
Notice the Count variable is allwys 1 because the FastCGi termination IS NOT outliving the request.
When I lower the number of bytes:
-------- 01-05-2009 22:42:28 ---------
1 Bytes sent= 2000
FastCGI Reply: Count= 1, ContentLen= 2000
2 Bytes sent= 2000
FastCGI Reply: Count= 2, ContentLen= 2000
3 Bytes sent= 2000
FastCGI Reply: Count= 3, ContentLen= 2000
Now the FastCGI process outlives each request and all is good.
The three requests take around 2 secs with my current connection.
All the timouts on the server are 10secs or more:
[C:\Inetpub\wwwroot\MyServer\cgi-bin\FCGITest.exa]
QueueLength=999
MaxInstances=20
InstanceTimeout=60
InstanceMaxRequests=500
IdleTimeout=10
ActivityTimeout=10
RequestTimeout=10
Is there something simple I have overlooked?
When I increase the Chunk Size to 64k, it still only takes about 3/4 seconds to complete:
-------- 01-05-2009 22:58:26 ---------
1 Bytes sent= 64000
FastCGI Reply: Count= 1, ContentLen= 64000
2 Bytes sent= 64000
FastCGI Reply: Count= 1, ContentLen= 64000
3 Bytes sent= 64000
FastCGI Reply: Count= 1, ContentLen= 64000
4 Bytes sent= 64000
FastCGI Reply: Count= 1, ContentLen= 64000
All the data is received ok.