This AutoIt Tutorial shows how to control the timeouts of your HTTP Requests. Changing the default timeouts can be useful to prevent rare problems, such as a page not downloading due to the connection timing out before any data is received.
The HTTP timeouts can be controlled trough the SetTimeouts method of the Winhttprequest.5.1 object.
Normally there is no reason to use the default timeouts for new connections. The reason for this is, that long response times rarely seem to be due to connection problems. If a long response time is encountered, it is usually because the server is offline, and then you will just waste valuable time trying to establish a connection.
HTTP Timeouts With AutoIt
To easily change the timeouts, we can simply change all of them at the same time, in one line of code.
The timeouts that you set with the above line of code are as follows:
|ResolveTimeout||Maximum time allowed to use when resolving a host name, such as beamtic.com, to an ip address.|
|ConnectTimeout||Maximum time allowed to spend when connecting to a server, if a server does not respond within this time, the connection is dropped.|
|SendTimeout||Timeout for individual packets. Larger packets are normally broken up into multiple smaller packets.|
|ReceiveTimeout||Timeout for incoming packets. Again, larger packets are normally broken into multiple smaller ones.|
All the timeouts are to be provided as milliseconds.
Where to use SetTimeouts in the AutoIt Script
When setting the timeouts, remember that it should be done before the send method, and after creating an object. I.e.
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "http://beamtic.com/", False) $oHTTP.SetTimeouts(30000,60000,30000,30000) $oHTTP.Send()