Tidhttp.connectTimeout不工作! [英] Tidhttp.connectTimeout not working!

查看:152
本文介绍了Tidhttp.connectTimeout不工作!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我使用tidhttp来发帖。当我尝试设置connectTimeout任何时间段没有任何效果。我还等待〜5秒才能得到例外。
提前感谢!

解决方案

如果要连接到主机名而不是IP地址,则主机名必须通过DNS查找解决IP,这可能需要时间,特别是如果主机名尚未被操作系统缓存。 ConnectTimeout不是零,或者如果使用了TIdAntiFreeze,那么Indy必须使用内部工作线程才能执行,否则,ConnectTimeout属性不会被考虑。



实际的socket API连接()调用服务器。根据当时可用的系统资源,启动新线程可能需要一些时间。 ConnectTimeout当前的实现仅适用于实际的套接字API connect()调用本身,而不是任何额外的工作。需要达到这一点。因此,如果您设置了5秒的ConnectTimeout值,则可能会在TIdTCPClient.Connect()退出之前经过超过5秒。


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!

解决方案

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.

这篇关于Tidhttp.connectTimeout不工作!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆