Hello I solved my problem, the thing was quite foolish, I had my server set up as HTTP 1.1. Connections to a single HTTP 1.1 server are limited to two simultaneous connections. http://support2.microsoft.com/kb/183110
Delphi Soap WebServer doesn't allow more than 2 calls at a time
-
17-06-2023 - |
문제
I have a problem with a SOAP WebServer: if I have a method on the server that takes a few seconds to give a result, and I can't make more than two calls "simoultaneously" (called from threads) from my client application (developed in Delphi Also - just for testing, the final client app will be web based). I mean that the threads are somehow serialized, and I don't know if it is supposed to happen like this or if I am doing something wrong, or if I need to make a certain setting.
Delphi XE2 Professional, Windows 7 64-bit
Link to my zipped project: http://1drv.ms/Nwu9nY
Server Method:
function TServiciu.Test: string;
var t0, t1, Duration : Cardinal;
Guid : tguid;
RGuid : HRESULT;
received : boolean;
const MaxTime : Cardinal = 3000;
begin
Result := '';
RGuid := CreateGuid(Guid);
if RGuid = S_OK then
Result := GuidToString(Guid);
t0 := GetTickCount;
t1 := GetTickCount;
duration := t1 - t0;
while (Duration < Maxtime) do begin
//waiting for something to be written in a db by another program
//I am doing querys to the database for that result
if received then begin
Result := Result + '_RECEIVED_' + DateTimeToStr(Now);
Break;
end;
t1 := GetTickCount;
duration := t1 - t0;
if duration > Maxtime then begin //MaxTime allowed is exceded
Result := Result + '_NOTRECEIVED_' + DateTimeToStr(Now);
Break;
end;
end;
end;
Client Procedure Execute of my thread:
procedure TThreadTest.Execute;
begin
try
// OleCheck will raise an error if the call fails
OleCheck(CoInitializeEx(NIL, COINIT_MULTITHREADED or COINIT_SPEED_OVER_MEMORY));
try
s := 'Calling Method Test; Result=' +
Self.ThGetService.Test;
Synchronize(self.ScrieRezultat); //write result in memo
finally
CoUninitialize;
FreeAndNil(self.ThHttprio);
end;
except
// We failed, do something
end;
end;
해결책 2
다른 팁
I am able to handle 40 concurrent calls with no trouble (actually more than that), but I'm using a different approach. My service is a CGI executable, so IIS manages the connections. When a SOAP request is made, IIS spins up a new instance of myapp_cgi.exe to handle the request. I top out at 40 TPS, but I am load-balanced across 4 servers so I can actually do 160 TPS, sustainable all day long, if necessary.
I just had a very similar problem and I'm pretty sure your problem is on your client, not on your server. See this topic here.