Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jul : ReadTimeout not working intermittently with TIdHTTPClient.Post

www.cryer.info
Managed Newsgroup Archive

ReadTimeout not working intermittently with TIdHTTPClient.Post

Subject:ReadTimeout not working intermittently with TIdHTTPClient.Post
Posted by:"Doug" (dougmund..@splyce.com)
Date:Wed, 19 Jul 2006 14:14:09

We've experienced some weird behavior on one of our systems that uses
TIdHttpClient.Post (with SSL), in that once in a while, while a user's ISP
is having connectivity issues, the ReadTimeout does not seem to work
correctly, and a response is received after the timeout period.  My
speculation is that the reply dribbles in, and that the ReadTimeout is
satisfied when part of the reply is received, but the entire reply is not
received until the timeout period has passed.  Example, timeout set to 45
seconds, reply comes in at 80 seconds.  This caused us lots of problems
because the timeout is built around a parent process with a longer timeout
and we end up with systems that are out of sync.  The parent process
thinking the first timed out and the first process with a valid (although
late) reply.  Most of the time when we have a connectivity issue, the
ReadTimeout works properly, just not always.

We are using Indy 9.0.14.  Other constraints - we have to use the Post
method, SSL, and embed control characters in the request (All 3rd party
constraints - not my choice!).

Thanks for any ideas or solutions tothis problem.

Doug


Here are relavant parts of the code:

MyHttpClient  := TIdHTTP.Create(MyhttpClient); //Create Indy Client Socket
MySSLIOHandler1 := TIdSSLIOHandlerSocket.Create(nil);
RequestTStringStream := TStringStream.Create(S);

MySSLIOHandler1.SSLOptions.Method := sslvSSLv23;
MyhttpClient.Port := 443;
MyhttpClient.IOHandler := IndySSLIOHandler1;
MyhttpClient.ReadTimeout := 4500;
MyhttpClient.CheckForDisconnect(False, True);

MyhttpClient.Request.CacheControl := 'no-cache';
MyhttpClient.HTTPOptions := [hoForceEncodeParams];
MyhttpClient.Request.ContentLength := Length(RequestString);

// had to use TStringStream cuz Indy will not remove ctrl characters with
StringStream
RequestTStringStream.WriteString(RequestString);
try
  ReplyString := MyhttpClient.Post(HostAddress, RequestTStringStream);
except
  on EIdReadTimeout do
  begin
      // perform TimeOutReversal of transaction...
      // & other steps...
  end;
end;

Replies:

www.cryer.info
Managed Newsgroup Archive