Share via:

Controlling HTTP Timeouts With AutoIt

How to change the HTTP Timeouts when using Winhttprequest.5.1 with AutoIt.


Edited: 2019-09-11 16:55

AutoIt Logo

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:

ResolveTimeoutMaximum time allowed to use when resolving a host name, such as, to an ip address.
ConnectTimeoutMaximum time allowed to spend when connecting to a server, if a server does not respond within this time, the connection is dropped.
SendTimeoutTimeout for individual packets. Larger packets are normally broken up into multiple smaller packets.
ReceiveTimeoutTimeout 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", "", False)