2

I'm working at an application which uses Indy's TIdHTTP component.

I send a request to my HTTP server, and it sends back a report. But, when the report is too long, I get this error:

Connection Closed Gracefully

Here is a part of my code:

procedure TdmAthlos.HttpClientAuthorization(Sender: TObject;  Authentication: TIdAuthentication; var Handled: Boolean);
begin
  HttpClient.Socket.Host                       := fOptiuni.edIP.Text;
  HttpClient.Request.BasicAuthentication       := True;
  HttpClient.Request.Authentication.Username   := fOptiuni.edUsername.Text;
  HttpClient.Request.Authentication.Password   := fOptiuni.edPassword.Text;
end;

procedure TdmAthlos.HttpClientConnected(Sender: TObject);
begin
  HttpClient.Socket.Binding.SetKeepAliveValues(True, 1500, 1000);
end;
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Vlad Costin
  • 61
  • 1
  • 10
  • 1
    How long does it take for the server to begin sending bytes for the report? You are setting a low-level timeout on the socket (instead of using Indy's own `ReadTimeout` property), so if the server takes awhile before sending anything, that could easily account for your error. Also, on a side note, you should not be setting the `Socket.Host` property at all. `TIdHTTP` handles that internally when establishing the TCP connection. – Remy Lebeau Apr 03 '17 at 15:57
  • After 2 minutes i get this error and server begin to send bytes immediately. – Vlad Costin Apr 05 '17 at 08:03
  • the only possible ways the server could send bytes immediately and still cause a 2 minute timeout is if either 1) it stops sending bytes before the end of the response has been sent, 2) the response is malformed in some way that causes `TIdHTTP` to expect more bytes than are actually sent, or 3) `TIdHTTP` has a logic bug somewhere. What versions of Delphi and Indy are you using? Do you get the same timeout in a web browser? Can you provide the actual URL so I can look at It? Or at least a capture from a packet sniffer? You can send them to me privately if they are sensitive. – Remy Lebeau Apr 05 '17 at 14:00

0 Answers0