We have calls that may take hours to complete and have been using the classical way to deal with this, which is to increase the timeout.
This works but it’s annoying to wait that long for a true “connection lost” scenario so I have started using the Async way of doing things, like this:
var Request := FAsyncService.BeginLengthyCall(Param1, Param2, Param3, procedure (const aRequest: IROAsyncRequest) begin end ); var TotalWaitTime := 0; while not Request.Done and (TotalWaitTime < 4 * 60 * 60 * 1000) do begin Sleep(500); Inc(TotalWaitTime, 500); end; if Request.Done then begin ResultValue := FAsyncService.EndLengthyCall(OutParameter, Request); end else begin raise EMyTimeout.Create('Timeout waiting for LengthyCall completion'); end;
While this works when
LengthyCall is responding fast (say less than 10 minutes), I sometimes get
EROTimeout exceptions when the call has waited for about 3 hours.
This is the call stack that I get:
uROAsync 497 +8 TROAsyncRequest.DoReadResponse uROAsync 548 +1 TROAsyncRequest.ReadResponse MyServerLibrary_Intf 10200 +1 TMyService_AsyncProxyEx.EndLengthyCall MyUnit 837 +30 TMyClass.DoSomething
It’s as if the server part (or client part) had given up on the call and does not cope with it well.
Does this ring a bell?