Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 May : TIME_WAIT port exhaustion

www.cryer.info
Managed Newsgroup Archive

TIME_WAIT port exhaustion

Subject:TIME_WAIT port exhaustion
Posted by:"Vlad Gonchar" (vgonch..@performancesoft.com)
Date:Wed, 25 May 2005 08:45:02

I have very simple http client that posts request with 1K payload:

procedure TForm1.DoPostIndy( const Url: string; const Payload: string );
var
  aContentStream: TStringStream;
  aResponse: string;
begin
  aContentStream  := TStringStream.Create( Payload );
  try
    //IdHTTP1.Request.Connection := 'keep-alive';  <=============does not
help
    IdHTTP1.Request.ContentType := 'application/octet-stream';
    aResponse := IdHTTP1.Post( Url, aContentStream );
  finally
    aContentStream.Free;
  end;
end;


and very simple http server, that simply returns received payload to the
client:

procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext;
                                         ARequestInfo: TIdHTTPRequestInfo;
                                         AResponseInfo:
TIdHTTPResponseInfo);
var
  aRequestContent, aProcessedData: string;
begin
  // get payload
  aRequestContent := TStringStream( ARequestInfo.PostStream ).DataString;

  // process received message here
  //...
  aProcessedData := aRequestContent; // send received content back to client

  // create response
  AResponseInfo.ContentType :=  'application/octet-stream';
  if AnsiSametext( ARequestInfo.Document, '/psvcrkrtr' ) then begin  //
process crk message
    AResponseInfo.ContentText := aProcessedData;
  end else begin // it is not a croak request
    AResponseInfo.ResponseNo := 404;
    AResponseInfo.ContentText := 'The requested URL ' +
ARequestInfo.Document + ' was not found on this server.' +#13#10 +
                                 'Only pbviews connection manager messages
are processed.';
  end;
end;

Both are with default settings. Indy 10. Delphi 5.
Questions:
1. After I run the client in a loop with 1000 iterations I see hundreds not
closed connections in state 2MSL close delay.
    AFAIK HTTP 1.1 uses persistent connections by default. But it looks like
something are still closing connections.
    How I can set Indy to make and maintain persistent connections? How I
can set using parallel and persistent connections?
2. Performance is very poor - 40 messages per second!? If I run 2 or 3
clients in the loop I get same overall performance (40msgs/sec).
    Individual performance of each client is 40/2 or 40/3 respectively. I
guess answer on first question will rectify this speed or in here something
    more I have to tune?

Replies:

www.cryer.info
Managed Newsgroup Archive