Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tidhttp.connectTimeout not working!

Tags:

delphi

indy10

So i'm using tidhttp to make post requests. when i try to set connectTimeout whatever period of time it has no effect. I still wait ~5 sec before i get exception. Thanks in advance!

like image 489
Peacelyk Avatar asked Feb 25 '23 18:02

Peacelyk


1 Answers

If you are connecting to a hostname instead of an IP address, the hostname has to be resolved to an IP via a DNS lookup, which can take time, especially if the hostname has not been cached by the OS yet. The ConnectTimeout property does not account for that time.

Also, when ConnectTimeout is not zero, or if TIdAntiFreeze is being used, Indy has to use an internal worker thread to perform the actual socket API connect() call to the server. Starting a new thread can take some time, depending on available system resources at that moment. ConnectTimeout does not account for that time, either.

The current implementation of ConnectTimeout applies only to the actual socket API connect() call itself, not to any of the extra work needed to reach that point. As such, if you have a 5 second ConnectTimeout value set, it is possible to hanve more than 5 seconds elapse before TIdTCPClient.Connect() exits.

like image 51
Remy Lebeau Avatar answered Mar 08 '23 13:03

Remy Lebeau